coderef

Promise.any()Baseline · Widely available

The Promise.any() static method returns a promise that fulfills as soon as the first of an iterable of promises fulfills, with that promise's value. Otherwise, it rejects with an AggregateError when all of the promises have rejected.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Sep 16, 2020. Widely available since Mar 16, 2023.

Browser support

DesktopChrome
1–84Not supported
85+Supportedsince Aug 25, 2020
Current: 155
Edge
12–84Not supported
85+Supportedsince Aug 27, 2020
Current: 154
Firefox
1–78Not supported
79+Supportedsince Jul 28, 2020
Current: 157
Safari
1–13.1Not supported
14+Supportedsince Sep 16, 2020
Current: 27
MobileChrome Android
18–84Not supported
85+Supportedsince Aug 25, 2020
Current: 155
Firefox Android
4–68Not supported
79+Supportedsince Jul 28, 2020
Current: 157
Safari iOS
1–13.4Not supported
14+Supportedsince Sep 16, 2020
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

JS
// Resolves with the first mirror that responds successfully
const fastest = await Promise.any([
  fetch("https://mirror-a.example/data.json"),
  fetch("https://mirror-b.example/data.json"),
]);

Feature detection

JS · check before using
if ("any" in Promise || ("prototype" in Promise && "any" in Promise.prototype)) {
  // Promise.any is available
}

Sub-features

Support for each part of the feature (5). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
AggregateError85857914857914
AggregateError.AggregateError85857914857914
AggregateError.errors85857914857914
AggregateError.serializable_object9898103179810317
Promise.any85857914857914