Skip to content

Instantly share code, notes, and snippets.

@nickydonna
Last active March 26, 2018 13:34
Show Gist options
  • Save nickydonna/72af87ab2ffb4823e998110c39d04680 to your computer and use it in GitHub Desktop.
Save nickydonna/72af87ab2ffb4823e998110c39d04680 to your computer and use it in GitHub Desktop.
// 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