Created
July 29, 2016 18:49
-
-
Save paulodiovani/a3cd29b5fde5525837f615ba5dcbba8c to your computer and use it in GitHub Desktop.
Promise chain example
This file contains hidden or 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
'use strict'; | |
new Promise((resolve, reject) => { | |
//resolve after 1 sec | |
setTimeout(() => { | |
resolve('chain 1'); | |
}, 1000); | |
}) | |
.then((c1) => { | |
console.log(c1); | |
return 'chain 2'; | |
}) | |
.then((c2) => { | |
console.log(c2); | |
return 'chain 3'; | |
}) | |
.then((c3) => { | |
console.log(c3); | |
return 'end chain'; | |
}) | |
.then((ec) => { | |
console.log(ec); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment