Error while sending parameters to EJS page from node js

ε祈祈猫儿з 提交于 2019-12-12 04:23:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!