Promise.all()

ES6+

Returns a single Promise that resolves when all of the promises in the iterable have resolved, or rejects when any promise rejects.

Syntax

Promise.all(iterable)

Parameters

iterable Iterable

An iterable of promises

Return Value

Promise

A Promise that resolves with an array of all the resolved values

Examples

JavaScript
const p1 = Promise.resolve(1);
const p2 = Promise.resolve(2);
const p3 = Promise.resolve(3);

Promise.all([p1, p2, p3])
  .then(values => console.log(values));
Output:
// [1, 2, 3]

Related Methods