Skip to content

Instantly share code, notes, and snippets.

@Amberlamps
Created July 8, 2017 09:31
Show Gist options
  • Save Amberlamps/4d9ff98c9263d72333ff10a8a109fe61 to your computer and use it in GitHub Desktop.
Save Amberlamps/4d9ff98c9263d72333ff10a8a109fe61 to your computer and use it in GitHub Desktop.
going full circle 2
app.get('/users/:userId', (req, res) => {
db.getUserAsync(req.params.userId, (err, user) => {
db.getPostsByUserAsync(user.id, (err, posts) => {
db.getCommentsByPostsAsync(posts, (err, comments) => {
res.json(mergeData(user, posts, comments));
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment