Skip to content

Commit bc7ac25

Browse files
author
stackcats
committed
add year list
1 parent ebab09d commit bc7ac25

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

api/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ module.exports = async (req, res) => {
2323
const currentYear = new Date().getFullYear();
2424
const years = _.range(2015, currentYear + 1);
2525
const stars = await Promise.all(_.map(years, year => fetch(year)));
26+
const doc = {};
27+
for (let i = 0; i < year; i++) {
28+
doc[years[i]] = `${stars[i]}*`;
29+
}
2630
const allStars = stars.reduce((acc, star) => acc + star);
31+
doc.allStars = `${allStars}*`
2732
console.log(allStars);
28-
res.json({
29-
allStars: `${allStars}*`,
30-
});
33+
res.json(doc);
3134
};

0 commit comments

Comments
 (0)