A promise object has one of three states:
promiseis created using a constructor that takes a call back function with two arguments (line 1).
then()method is called when the promise is resolved, and the
catch()method is called if the promise is rejected or if there was an error during the code execution (lines 10-11).
Promise.all() method returns a single promise that resolves when all of the passed-in promises have resolved. It rejects if one of the promises is rejected.
Promise.race() method returns a promise that resolves or rejects as soon as one of the promises resolves or rejects. The
fromRes method contains the value from the promise that is resolved first.
View all Courses