Created
December 4, 2017 23:12
-
-
Save suryadutta/f364c533af0b584f4857ce12dbc8ba54 to your computer and use it in GitHub Desktop.
async.js
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
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