【发布时间】:2020-03-26 22:14:39
【问题描述】:
如果有效负载为空,我需要一个代码来响应错误。我该怎么做?
if(req.body !== {}){
res.json(newUser)
}else{
res.status(400).json('fill in the necessary information')
}
【问题讨论】:
-
您的支票有什么问题?它是作为未定义的对象还是空对象
{}进来的? -
同样设置状态后需要
res.send("whatever")
标签: javascript node.js reactjs express jsx