Better handling of rejections using Promise.allSettled()
When it comes to executing several Promises concurrently and waiting for them all to finish before using their resolved values elsewhere in your code, Promise.all()
is really useful.
The problem is though, that if one of those Promises fails/rejects, all the function calls will still happen, but the return value you'll get will just be the value of the first rejected Promise.
And because of this - in situations where you still want to get those values from the Promises that did resolve, Promise.all()
is not the best solution.
There is a way around this though...