Promise.any

Return the result of the first promise that resolves successfully.

Code

General
const promises = [
  new Promise(r => setTimeout(() => r('slow'), 100)),
  Promise.resolve('first'),
  Promise.reject(new Error('fail'))
];

return await Promise.any(promises);
Browser·fetch() may be limited by CORS

More JavaScript Snippets