问题
I am sending parameters from node js to an EJS page as...
router.get("/AdminDatabase", function(req, res) {
res.render('Pages/AdminDatabase', { title: 'WebFormsAdmin', role: req.cookies.role });
});
How can I do the same in the below code..
router.get('/CreateSurvey', function(req, res, next) {
var Education = QBank.findOne({_id:"id1"});
var Political = QBank.findOne({_id:"id2"});
var resources = {
education: Education.exec.bind(Education),
political: Political.exec.bind(Political)
};
async.parallel(resources, function (error, results){
if (error) {
res.status(500).send(error);
return;
}
res.render('Pages/CreateSurvey', results);
});
});
I tried this as below, but that gives me some error. The page is not rendering. It says error.. failed to look in view. Can anyone help in this?
res.render('Pages/CreateSurvey', {results: results, title: 'WebFormsAdmin', role: req.cookies.role });
I think the problem is the way I pass the parameters here. The results is the problem here
来源:https://stackoverflow.com/questions/42734396/error-while-sending-parameters-to-ejs-page-from-node-js