Created
April 4, 2019 20:03
-
-
Save patmigliaccio/22d9e1195d458e947affa159db4446fe to your computer and use it in GitHub Desktop.
patmigliaccio.com/resolving-nested-promises 4/4/19
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
function resolveComments(user) { | |
return Promise.all( | |
user.commentIds.map(commentId => { | |
return comments.getCommentById(commentId) | |
}) | |
); | |
} | |
const activeUsers = await post.getActiveUsers(); | |
const activeUsersFullComments = activeUsers.map(async user => { | |
user.comments = await resolveComments(user) | |
return user; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment