Skip to content

Instantly share code, notes, and snippets.

@taniarascia
Last active February 13, 2024 07:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taniarascia/1aba40266c414814f06b0ec1c7597d87 to your computer and use it in GitHub Desktop.
Save taniarascia/1aba40266c414814f06b0ec1c7597d87 to your computer and use it in GitHub Desktop.
async
method1 = async () => {
const things = await getThings()
for (let thing of things) {
const stuff = await getStuffFromThing(thing)
console.log(stuff) // works
}
}
method2 = async () => {
const things = await getThings()
await Promise.all(things.map(async thing => {
const stuff = await getStuffFromThing(thing)
console.log(stuff) // works
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment