Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demystifying Async Programming in Javascript - fetchJson promise fixed
.then(function (user) {
return fetchJson('/api/user/interests?userId=' +
.then(interests => {
user: user,
interests: interests
.then(function (blob) {
return Promise.all[ => fetchJson('/api/recommendations?topic=' + i))]
.then(recommendations => {
user: blob.user,
interests: blob.interests,
recommendations: recommendations
.then(function (bigBlob) {
render(bigBlob.user, bigBlob.interests, bigBlob.recommendations);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.