Created
July 12, 2016 01:01
-
-
Save kenichi-shibata/ac22917b7a1215522c640146fa2ca814 to your computer and use it in GitHub Desktop.
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
var Promise = require('bluebird'); | |
function a(val){ | |
return new Promise(function(resolve){ | |
val++; | |
resolve(val); | |
}); | |
} | |
function b(val){ | |
return new Promise(function(resolve,reject){ | |
val++; | |
reject(val); | |
}); | |
} | |
a(0) | |
.then(b) | |
.then(function(value){ | |
console.log('total value: '+ value); | |
}) | |
.catch(function(err){ | |
console.log('errored @ '+ err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment