![]() |
VOOZH | about |
JavaScript Promise any() method is a static method that takes an array of promises as a parameter and returns the first fulfilled promise. It returns a rejected value when all of the promises in the array return rejects or if the array is empty. When all the promises are rejected an AggregateError is returned which contains the reason for rejection.
Syntax:
Promise.any(iter)Parameters: It takes only one parameter.
Return Value: It returns a promise which is:
Example 1: This example, shows the basic use of Promise.any() method.
Example 2: This example shows how the promise is rejected in any method.
We have a complete list of Javascript Promise methods, to check those please go through the article.