bhylu.com

Advertisements

Async Reference

AllSettled reports both fulfilled and rejected outcomes. Use it when each independent result should be inspected.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const results = await Promise.allSettled([
  Promise.resolve(12),
  Promise.reject(new Error("Unavailable"))
]);
console.log(results.map(result => result.status));

What happens

The statuses are fulfilled and rejected.