Lurker News
Back to discussion

Comment by mromnia

mromnia1 reply#
Iterating with async/await means you wait for every result before making another call. You basically execute the async calls one by one.

Promise.all runs them all simultaneously and waits until they are all complete. It returns an array of results in the same order as the calls, so it's usually pretty straightforward to use.
Both approaches have a purpose, so it's not like you "should" strictly use one. But you should be aware of both and be able to use the one that fits the need.

dmix#
The third major strategy being Promise.any():

- as soon as any of them resolve (any)
- when all of them resolve (all)
- resolve each in order (for)