【发布时间】:2020-05-04 10:05:22
【问题描述】:
有一个与 expressJS 相关的表单。当我按下提交按钮时,将输入数据(图像方向)形成一个路径,我通过 router.post() 函数得到它。
当我发送错误的图像方向时,图像状态的响应是404。
问题是如何获得此状态。我想把它放在一个变量中。
表格代码:
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 代码:
module.exports.postAddProduct = (req, res) => {
console.log(req.body.name);
res.redirect('/');
};
【问题讨论】:
-
贴代码!!!
-
我已经发布了
标签: javascript node.js express ejs