Last active
June 11, 2019 03:33
-
-
Save copperwall/093fe7758398643e532c0fa246001c77 to your computer and use it in GitHub Desktop.
This file contains 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
function getGuides() { | |
let ids = [...Array(10).keys()]; | |
return ids.reduce((accumulator, id) => { | |
return accumulator.then(results => { | |
return fetch(id).then(result => { | |
results.push(result); | |
return results; | |
}); | |
}); | |
}, Promise.resolve([])); | |
for (let i = 1; i <= 10; i++) { | |
let res = await fetch(`/api/2.0/guides/${i}`); | |
results.push(res); | |
} | |
return results; | |
} | |
getGuides().then(guides => console.log(guides)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment