Home

allSettled

allSettled is a static method on the JavaScript Promise object. It is defined as Promise.allSettled(iterable) and returns a new Promise that resolves after all of the input promises have settled, meaning they have either fulfilled or rejected. The resolved value is an array describing the outcome of each input, in the same order as the input iterable.

The result array contains objects with a uniform shape. For a fulfilled input, the corresponding element is

Syntax and behavior notes: allSettled accepts any iterable of promises or values and returns a promise that

Example:

const promises = [

Promise.resolve(1),

Promise.reject(new Error('boom')),

3

];

Promise.allSettled(promises).then(results => console.log(results));

// [{ status: 'fulfilled', value: 1 }, { status: 'rejected', reason: Error('boom') }, { status: 'fulfilled', value: 3 }]

History and compatibility: allSettled was introduced in ECMAScript 2020 (ES11). It is supported in modern browsers

{
status:
'fulfilled',
value:
...
}.
For
a
rejected
input,
the
element
is
{
status:
'rejected',
reason:
...
}.
If
an
input
is
not
a
promise,
it
is
treated
as
a
fulfilled
value
and
included
as
{
status:
'fulfilled',
value:
...
}.
The
method
does
not
short-circuit
on
rejection,
so
it
waits
for
all
inputs
to
settle.
resolves
to
the
array
of
outcome
objects
when
all
have
settled.
If
the
iterable
is
empty,
it
resolves
immediately
to
an
empty
array.
Unlike
Promise.all,
allSettled
never
rejects;
it
always
resolves
with
the
outcomes
of
all
inputs.
and
Node.js
(around
Node
12
onward).
Polyfills
are
available
for
older
environments.
Use
allSettled
when
you
need
a
complete
picture
of
multiple
asynchronous
operations,
regardless
of
whether
some
fail.
See
also
Promise.all,
Promise.any,
and
Promise.race
for
alternative
aggregation
patterns.