Skip to content

Instantly share code, notes, and snippets.

@rbren
Last active October 11, 2017 15:48
Show Gist options
  • Save rbren/9e405137c21e88bc5bc475b8105a1393 to your computer and use it in GitHub Desktop.
Save rbren/9e405137c21e88bc5bc475b8105a1393 to your computer and use it in GitHub Desktop.
let hn = require('@datafire/hacker_news').create();
(async () => {
let storyIDs = await hn.getStories({storyType: 'top'});
// Using for loop (runs in series)
for (let itemID of storyIDs) {
let details = await hn.getItem({itemID});
console.log(details);
}
// Using Promise.all (runs concurrently)
let detailSet = await Promise.all(storyIDs.map(itemID => hn.getItem({itemID})));
detailSet.forEach(console.log);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment