allSettled
allSettled is a static method on the JavaScript Promise object. It is defined as Promise.allSettled(iterable) and returns a new Promise that resolves after all of the input promises have settled, meaning they have either fulfilled or rejected. The resolved value is an array describing the outcome of each input, in the same order as the input iterable.
The result array contains objects with a uniform shape. For a fulfilled input, the corresponding element is
Syntax and behavior notes: allSettled accepts any iterable of promises or values and returns a promise that
Promise.reject(new Error('boom')),
];
Promise.allSettled(promises).then(results => console.log(results));
// [{ status: 'fulfilled', value: 1 }, { status: 'rejected', reason: Error('boom') }, { status: 'fulfilled', value: 3 }]
History and compatibility: allSettled was introduced in ECMAScript 2020 (ES11). It is supported in modern browsers