Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save godspeedelbow/5a8ca432948462fd6d0b8b129b9eb66c to your computer and use it in GitHub Desktop.
Save godspeedelbow/5a8ca432948462fd6d0b8b129b9eb66c to your computer and use it in GitHub Desktop.
const run = (userId) => {
async.waterfall([
callback => {
async.parallel([
cb => getUser(userId, cb),
cb => getPosts(userId, cb),
], callback);
},
([user, posts], callback) => {
getComments(posts, (err, comments) => callback(err, user, posts, comments));
},
(user, posts, comments, callback) => {
parsePostsWithComments(user, posts, comments, callback);
},
], (err, postsWithComments) => {
if (err) {
console.log('err', err);
} else
console.log('postsWithComments', postsWithComments);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment