Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
async/await with fetch and map
// Use hacker news API as example
async function getData() {
const ids = await (await fetch('')).json()
const data = Promise.all( (i) => await (await fetch(`${i}.json?print=pretty`)).json())
return data
.then(data => {
// Async/await is just a different way of writing promises.
// Even though it looks like synchronous code, don't think it that way.
// It ain't what you don't know that gets you into trouble. It's what you know for sure that just ain't so.
// It ain't asynchrony that gets you into trouble. It's what you think is synchronous that just ain't so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.