Last active
May 22, 2018 22:31
-
-
Save paulbreslin/2cbd49e98e53eafba2ab8af385646e90 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
const example = require('example-library'); | |
example.firstAsyncRequest() | |
.then( fistResponse => { | |
example.secondAsyncRequest(fistResponse) | |
.then( secondResponse => { | |
example.thirdAsyncRequest(secondResponse) | |
.then( thirdAsyncResponse => { | |
// Insanity continues | |
}); | |
}); | |
}); |
Or even:
example.firstAsyncRequest()
.then(firstResponse => example.secondAsyncRequest(firstResponse))
.then(secondResponse => example.thirdAsyncRequest(secondResponse))
.then(thirdResponse => {
// you can keep coding with sanity :)
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could do it this way:
Promise are here to resolve the callback hell, no need to do it again with them ahah