Vijay pandey Vijay pandey - 1 year ago 143
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 Source

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download