Skip to content

Instantly share code, notes, and snippets.

@bitfishxyz
Created April 29, 2020 04:22
Show Gist options
  • Save bitfishxyz/d6e93580e8466bea36c05262a488f109 to your computer and use it in GitHub Desktop.
Save bitfishxyz/d6e93580e8466bea36c05262a488f109 to your computer and use it in GitHub Desktop.
var p = new Promise(function(resolve, reject){
resolve(1);
});
p.then(function(value){ //1st then
console.log(value);
return Promise.resolve(value*2);
}).then(function(value){ //2nd then
console.log(value);
return Promise.resolve(undefined)
}).then(function(value){ //3rd then
console.log(value);
return Promise.resolve('resolve');
}).then(function(value){ //4th then
console.log(value);
return Promise.reject('reject');
}).then(function(value){ //5th then
console.log('resolve: '+ value);
}, function(err){
console.log('reject: ' + err);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment