'API function doesn't run
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?
Solution 1:[1]
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...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Skayu |
