There is a form which connected with expressJS. When i press the submit button, form post input data(image direction) to a path and i am getting it with router.post() function.
When i send wrong image direction, the response of image status is 404.
Question is How can i get this status. I want to put it in a variable.
form code:
extends ../layouts/main-layout.pug
block content
form(action='/admin/add-product', method='POST')
.row
.input-field.col.s6
input#name.validate(name ='name',type='text', placeholder='Please Enter A Product Name')
.input-field.col.s6
input#name.validate(name='image',type='text', placeholder='Please Enter A Product Image')
.input-field.col.s6
input#name.validate(name='state',type='text', placeholder='Please Enter A Product State')
.input-field.col.s6
input#name.validate(name='price',type='text', placeholder='Please Enter A Product Price')
.input-field.col.s12
button.btn.waves-effect.waves-light(type='submit', name='submit')| Submit
router.get code:
module.exports.postAddProduct = (req, res) => {
console.log(req.body.name);
res.redirect('/');
};
Console the response and access it like console.log(res.status);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.