API函数不运行
我有以下 api 函数:
value = req.body;
initalBoardID = value.model.id;
value = value.action;
type = value.type;
translationKey = value.display.translationKey;
res.status(200).json("Okay");
if (
type == "addMemberToCard" &&
translationKey == "action_member_joined_card"
) {
member = value.display.entities.memberCreator.id;
createCard();
}
} else {
res.status(200).json("Function works");
}
当我向上述函数发送 POST 请求时,我得到状态 200,但代码不会继续。
我还有一个 api 函数来获取一些信息和错误。
当我调用此函数时,代码将继续。但我没有调用任何函数来记录此 api 的信息或错误。
你知道为什么代码不从头继续吗?仅当我调用另一个不记录任何信息和错误的 api 时?
I have following api function:
value = req.body;
initalBoardID = value.model.id;
value = value.action;
type = value.type;
translationKey = value.display.translationKey;
res.status(200).json("Okay");
if (
type == "addMemberToCard" &&
translationKey == "action_member_joined_card"
) {
member = value.display.entities.memberCreator.id;
createCard();
}
} else {
res.status(200).json("Function works");
}
When I send a POST request to the above function I get the status 200 but the code doesn't continue.
I have also an api function to get some inforamtion and errors.
When I call this function the code continues. But I don't call any function to log a information or an error of this api.
Do you know why the code doesn't continue from the beginning? Only when I call another api which does not log any information and errors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我没看错的话,如果您发送 res.status 或 res.json,则无法发送其他响应。另外,如果您发送响应,代码就会中断,因此它不会走得更远,因此当您有 res.status 等时, createCard() 将不会运行,因为该函数在发送响应后停止...
If I read things correctly, if you send res.status or res.json, you can't send another response. Also if you send response, the code breaks, so it doesn't go far more, so as you have res.status etc. and then createCard() won't run because the function stops after sending response...