res.status().send()
将只向客户端发送状态代码,但不会向客户端发送位于
send()
.
这是我的代码(为简洁起见,编辑了所有代码,但问题是):
exports.user_signup = (req, res) => {
const { body } = req;
const { companyName, password, email } = body;
User.find({ email: email }, (err, previousUsers) => {
if (err) {
return res.status(400).send({
message: "There was an issue signing up."
});
} else if (previousUsers.length > 0) {
return res.status(403).send({
message: "Records show this email is linked to another account."
});
}
}
当我做出决定的时候
fetch request
从客户端,响应只返回
status code
来自服务器,但响应中没有响应中的对象
发送()
方法。我只是随地吐痰
res.status(200).json(object)
json
这是我从客户端发出的“获取”请求:
fetch("http://localhost:3000/users/accounts/", {
method: "post",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(userData)
}).then(response => console.log(response));
}
Response {type: "basic", url: "http://localhost:3000/users/accounts/", redirected: false, status: 403, ok: false, â¦}
因此,我能够成功地将状态从路由发送回客户机,但我始终无法找出原因
发送()
不随对象一起发送。