Skip to content
Discussion options

You must be logged in to vote

Array.prototype.forEach ignores the promise your async callback returns, so it fires all callbacks and moves on without awaiting any of them — your code after the loop runs before the async work finishes. Use a for...of loop with await for sequential work, or await Promise.all(arr.map(async x => ...)) to run them concurrently and wait for all.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kevinchamplin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant