Friday 22 February 2019

Correct way to end code execution after res.send()

After a res.send() is used I want to end code execution, so to do this I've used a return statement like below:app.post('/someEndPoint', (res, res) => { if (someCondition) { return res.send('success'); } /*Some other code that will not execute because a return statement was used above*/ }); After doing some searches on Stackoverflow, some posters recommend this as a way of ending code execution, while others state that doing this is "semantically incorrect".Is what I did fine, or should I not be doing this?

Submitted February 23, 2019 at 03:54AM by MonkeyOnARock1

No comments:

Post a Comment