Skip to content

Instantly share code, notes, and snippets.

@oscarkuo
Created April 5, 2017 09:12
Show Gist options
  • Save oscarkuo/4b4db7ff88496d43ba141465969c9c54 to your computer and use it in GitHub Desktop.
Save oscarkuo/4b4db7ff88496d43ba141465969c9c54 to your computer and use it in GitHub Desktop.
How catch works with multiple promises?
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