我试图将错误响应返回给客户端,但只有当我将状态代码设置为200或500时才会返回。当我设置为304时,它不会返回消息。我错过了什么请澄清
res.send(304, {
message: 'cannot update config with empty value'
});
............................................... .................................................. ..............................
// update configure options
exports.update = function(req, res) {
if (req.body.items) {
// if items exists do something
....
....
} else {
// returns error message when set to 200 or 500 but does not when 304
// ie.,response body is empty
res.send(304, {
message: 'cannot update config with empty value'
});
}
};
答案 0 :(得分:-1)
试试这个
res.status(304).send({
message: 'cannot update config with empty value'
});