DEV Community

Discussion on: About async functions

Collapse
 
mike4040 profile image
Mike Kravtsov

I think important to add that async / await doesn’t work inside Array built in iterator functions, like .forEeach.
What is really bad that this behavior often not mentioned in tutorials, not get caught by linters, and didn’t throw error.
Good news is that there is a way to make it work, but it’s a topic for another article:)

Collapse
 
tkdodo profile image
Dominik D

good point. Am I right in thinking that it works with awaiting Promise.all of the result array, if used with .map instead of with .forEach ?

Collapse
 
leandroandrade profile image
Leandro Andrade

Be careful when using Promise.all because if one Promise fails in the Promises set, the others will still run.