Promise.race()

The Promise.race() static method takes an iterable of promises as input and returns a single Promise . This returned promise settles with the eventual state of the first promise that settles.

Try it