I have an url like this: http://localhost/editblog/58a5da1df3ec9614fc9893d3
and code in pug like this:
input.form-control(type='hidden', name='id', value='')
The question is how to get the value on the url and pass it to value=''
I've known about req.params.id
but it is not what could solve my issue
When you render your pug template you could send any variable as res.locals
property so it will send to template:
app.get('/editblog/:id', function(req, res) {
res.render('editblog', { title: 'edit blog', id: req.params.id });
});
And now you have access to id
whithin your template:
editblog.pug:
input.form-control(type='hidden', name='id', value=id)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With