> I was reading the MDN docs on JavaScript promises and realized that the difference between Promise.all and Promise.allSettled wasn’t immediately obvious.
Really? I haven't dealt with JavaScript in a while so I took a look at the MDN docs and it seems pretty obvious.
> The Promise.all() method returns a single Promise that fulfills when all of the promises passed as an iterable have been fulfilled
and
> The Promise.allSettled() method returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
`all` flattens all of the promises in a single promise containing an array of their results while `allSettled` flattens the promises into a single promise containing an array of objects that contain the resulting value as well as the status (which is either fulfilled or rejected).
The one catch that's not immediately obvious is pointed out by the article which is that `all` will resolve on the first rejected promise. Except that's also in the first paragraph of the doc:
>It rejects with the reason of the first promise that rejects
Really? I haven't dealt with JavaScript in a while so I took a look at the MDN docs and it seems pretty obvious.
> The Promise.all() method returns a single Promise that fulfills when all of the promises passed as an iterable have been fulfilled
and
> The Promise.allSettled() method returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.
`all` flattens all of the promises in a single promise containing an array of their results while `allSettled` flattens the promises into a single promise containing an array of objects that contain the resulting value as well as the status (which is either fulfilled or rejected).
The one catch that's not immediately obvious is pointed out by the article which is that `all` will resolve on the first rejected promise. Except that's also in the first paragraph of the doc:
>It rejects with the reason of the first promise that rejects