Promise.allSettled

Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.

Syntax

allSettled(values)

Parameters

Return value

A new Promise.

Return value

A new Promise.

The value of the returned promise is an array of objects with the following properties:

Examples

let p1 = new Promise(resolve => resolve(1))
let p2 = new Promise((resolve, reject) => reject(2))
let pp = Promise.allSettled([p1, p2])
pp.then(values => print(JSON.stringify(values)))
[{"status":"fulfilled","value":1},{"status":"rejected","reason":2}]