Created
April 5, 2017 09:12
-
-
Save oscarkuo/4b4db7ff88496d43ba141465969c9c54 to your computer and use it in GitHub Desktop.
How catch works with multiple promises?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let test1 = new Promise(function(resolve, reject) { | |
resolve('promise 1 result'); | |
//reject('promise 1 result'); | |
}); | |
test1 | |
.then((test1Result) => { | |
console.log('then 1 ' + test1Result); | |
return new Promise(function(resolve, reject) { | |
reject('promise 2 result'); | |
}); | |
}) | |
.then((test2Result) => { | |
console.log('then 2 ' + test2Result); | |
}) | |
.catch((resultFromWhicheverPromiseFailed) => { | |
console.log('catch ' + resultFromWhicheverPromiseFailed); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment