DEV Community

Discussion on: New Features in ECMAScript 2021 (with code examples)

Collapse
martijn_scheffer_f5485f4b profile image
Martijn Scheffer • Edited on

WHEN does Promise.any throw an error ? how can it know that none of the promise will be resolved later ?

did you mean that when ALL promises are rejected an exception is thrown ? that isn't exactly the same

Collapse
faithfulojebiyi profile image
Faithful Ojebiyi Author

When you use Promise.any, your literally saying which ever promise resolves first. It would only throw an error if non resolves.

If you want to make sure all your promise resolves or you want to catch error when any of the promises is rejected you should use Promise.all instead