I'm trying to render "result" in my "home-page" view using this function in my controller, which is calling my model to make the query.
exports.searchNoms = (req, res) => {
getDatabaseModel.searchNoms(req).then(function(result) {
console.log(result);
res.render('Home/home-page', {
nomenclature: result
});
}).catch((err) => setImmediate(() => {
throw err;
}))
};
I'm getting my result which displays a string as I wanted.
But then I'm getting the following error :
TypeError: Cannot read property 'render' of undefined at C:\somepath\controllers\nomenclature.controller.js:36:14
I've tried a few things and if I change my route calling this function in my controller from :
`router.post('/search-noms', function (req, res) {nomenclatureController.searchNoms(req.body.idNoms)})`
To :
`router.post('/search-noms', nomenclatureController.searchNoms)`
It works. But I need that body parameter in order to achieve what I want to do.
Am I missing something here ?