Creates a Promise that is resolved with an array of results when all of the provided Promises resolve or reject.
allSettled(values)
values
An iterable of Promises.
A new Promise.
A new Promise.
The value of the returned promise is an array of objects with the following properties:
status
Either “fulfilled” or "rejected".
value
The value of the resolved promise.
reason
The reason of the rejected promise.
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}]