如何获取响应体的元素状态?

编程入门 行业动态 更新时间:2024-10-11 07:26:41

如何获取响应体的<a href=https://www.elefans.com/category/jswz/34/1771401.html style=元素状态?"/>

如何获取响应体的元素状态?

有一个用expressJS连接的表单,当我按下提交按钮时,表单将数据(图片方向)输入到一个路径上,我用router.post()函数得到。 当我按下提交按钮时,表单将输入的数据(图像方向)发布到一个路径上,我用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 code :

module.exports.postAddProduct = (req, res) => {
    console.log(req.body.name);
    res.redirect('/');
};
回答如下:

Console的响应和访问它像 console.log(res.status);

更多推荐

如何获取响应体的元素状态?

本文发布于:2024-05-13 12:57:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1759577.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   状态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!