davidwalsh.name davidwalsh.name

Promise.allSettled

The Promise object has many useful functions like all, resolve, reject, and race — stuff we use all the time. One function that many don’t know about is Promise.allSettled, a function that fires when all promises in an array are settled, regardless of whether any of the promises are resolved or rejected. Promise.all is great but then isn’t called if a project is rejected: Promise.all([ Promise.resolve(1), ...