Created
March 12, 2017 18:43
-
-
Save mightyguava/3646f493dbc8e5fc0d24b2ce2545f885 to your computer and use it in GitHub Desktop.
Demystifying Async Programming in Javascript - fetchJson promise
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
fetchJson('/api/user/self') | |
.then(function (user) { | |
return fetchJson('/api/user/interests?userId=' + self.id); | |
}) | |
.then(function (interests) { | |
return Promise.all[interests.map(i => fetchJson('/api/recommendations?topic=' + i))]; | |
}) | |
.then(function (recommendations) { | |
render(user, interests, recommendations); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment