Last active
March 26, 2018 13:34
-
-
Save nickydonna/72af87ab2ffb4823e998110c39d04680 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
// option one - using Promise.all - I like this the most | |
asyncAuth() | |
.then(user => { | |
return Promise.all([user, asyncFetch(user)]) | |
}) | |
.then(([user, data]) => { | |
// ... | |
}); | |
// option two - nesting | |
asyncAuth() | |
.then(user => { | |
return asyncFetch(user) | |
.then(data => { | |
// ... | |
}); | |
}); | |
// option three - I'll kill you | |
let user; | |
asyncAuth() | |
.then(u => { | |
user = u; | |
return asyncFetch(user) | |
}) | |
.then(data => { | |
// ... | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment