Created
May 30, 2017 04:16
-
-
Save velotio-tech/1aedf5168efe5a23738bf828010d1233 to your computer and use it in GitHub Desktop.
NodeJS Chaining Using 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
var foo = function (arg) { | |
return new Promise((resolve, reject) => { | |
resolve(arg+1); | |
}); | |
} | |
var bar = function (arg) { | |
return new Promise((resolve, reject) => { | |
resolve(arg+2); | |
}); | |
} | |
var baz = function (arg) { | |
return new Promise((resolve, reject) => { | |
resolve(arg+3); | |
}); | |
} | |
var log = function (arg) { | |
console.log(arg); | |
} | |
foo(0) | |
.then(bar) | |
.then(baz) | |
.then(log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment