0
在路由器中,我通常使用req.json(object)
来返回正确的结果。现在,在某些情况下,我需要返回的错误信息,例如打破功能并看到错误信息
router.post('/register', function (req, res, next) {
if (req.body.username === null || req.body.username === undefined) {
console.log("all fields please");
// return res.status(400).json({ message: 'all fields please'});
// res.send('all fields please')
}
console.log("not finished")
}
我试图return res.status...
和res.send...
,他们要么没有完成或打破了功能,或者无法显示信息到控制台。
有谁知道哪个是正确的方法来做到这一点?
你试过'返回res.status'和'res.send'在一起? – wrangler
不,无论是其中一个或其他... – SoftTimur
返回将明显打破功能.....什么味精你在控制台预测''不完成'??? – wrangler