I have router and need to fetch data from two different collections. How can I do this without callbacks?
router.get('/menu/:id', function(req, res, next) {
var product = Product.find({menu: req.params.id}, function(err, products){
var menu = Menu.findOne({_id: req.params.id}, function(err, menu){
res.render('menu', {
user: req.user,
csrfToken: req.csrfToken(),
current_menu: menu,
products: products
});
});
});
});
as @tadman said it will be useful to use
async/await: