Skip to content

Instantly share code, notes, and snippets.

@suryadutta
Created December 4, 2017 23:12
Show Gist options
  • Save suryadutta/f364c533af0b584f4857ce12dbc8ba54 to your computer and use it in GitHub Desktop.
Save suryadutta/f364c533af0b584f4857ce12dbc8ba54 to your computer and use it in GitHub Desktop.
async.js
router.get('/', function(req, res, next) {
if (req.query.id) {
asyncStuff.series([
function(callback) {
moduleModel.getPageItems(req.query.id, function(Data) {
pageData = Data[0];
console.log('task 1');
callback();
});
},
function(callback) {
moduleModel.getPageVideos(req.query.id, function(VideoData) {
pageData.videos = VideoData;
console.log('task 2');
callback();
});
}
], function(err) { //This function gets called after the two tasks have called their "task callbacks"
if (err) return next(err);
console.log(pageData);
res.render('module', {
data: pageData,
});
});
} else {
res.send("Enter ID ");
}
});
module.exports = router;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment