Partly off-topic, but in JS I tend to avoid iterating over promises with maps because it's always confusing what will/won't work, so I use a basic FOR loop because async/await works in there.
How bad is this? Should I switch to Promise.all instead?
How bad is this? Should I switch to Promise.all instead?
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.
- as soon as any of them resolve (any)
- when all of them resolve (all)
- resolve each in order (for)