Promise.allSettled()

ES2020+

Returns a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects describing each outcome.

Syntax

Promise.allSettled(iterable)

Parameters

iterable Iterable

An iterable of promises

Return Value

Promise

A Promise that resolves with an array of result objects

Examples

JavaScript
Promise.allSettled([
  Promise.resolve('성공'),
  Promise.reject('실패'),
  Promise.resolve('또 성공')
]).then(results => {
  results.forEach(r => console.log(r.status));
});
Output:
// 'fulfilled' 'rejected' 'fulfilled'

Related Methods