Last active
October 11, 2017 15:48
-
-
Save rbren/9e405137c21e88bc5bc475b8105a1393 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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