Vijay pandey Vijay pandey - 1 month ago 9
Jade Question

How to send parameters with hyperlink HREF in jade and access it in routes expressJs

I am sending parameter from my jade

a(href="/service-labourJobcardnumber=#{Jobcardnumber}") add labour


but it is not treating it as a parameter.How to send the parameter with jade and how can i access it in my index.js routes.
This is my index.js code

router.get('/service-labour/:Jobcardnumber', function(req, res) {
var db = req.db;
var locals = {};
console.log(req.params); return;
locals.Jobcardnumber = req.body.Jobcardnumber;
res.render('service-labour', locals);
});


But its not working.

Answer

Thanks for your response but i found the answer my mistake was i was using

locals.Jobcardnumber = req.params.Jobcardnumber;

but it should be

locals.Jobcardnumber = req.query.Jobcardnumber;