As far as I know, there are two options about promise:
promise.all()
promise.race()
Ok, I know what promise.all()<
Here's an easy example to understand the use of promise.race()
:
Imagine you need to fetch some data from a server and if the data takes too long to load (say 15 seconds) you want to show an error.
You would call promise.race() with two promises, the first being your ajax request and the second being a simple setTimeout(() => resolve("ERROR"), 15000)