JavaScript Promise.allSettled()

Example

// Create a Promise
const myPromise1 = new Promise((resolve, reject) => {
  setTimeout(resolve, 200, "King");
});

// Create another Promise
const myPromise2 = new Promise((resolve, reject) => {
  setTimeout(resolve, 100, "Queen");
});

// Settle All
Promise.allSettled([myPromise1, myPromise2]).then((results) =>
  results.forEach((x) => myDisplay(x.status)),
);
Try it Yourself »

Description

The Promise.allSettled() method returns a single Promise from a list of promises, when all promises sette.


Syntax

Promise.allSettled(iterable)

Parameters

iterable An Array of promises

Return Value

Type Description
Object A new Promise Object


Browser Support

Promise.allSettled() is supported in all modern browsers since March 2020:

Chrome 76 Edge 79 Firefox 71 Safari 13 Opera 63
May 2019 Nov 2019 Mar 2020 Sep 2019 Aug 2019


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.