Reputation:
I have problem in the try/catch block here's the code :
catch((err) => {
winston.error(new Date() +' : '+req.originalUrl +' : '+`${id}`+' : '+err);
res.status(500);
})
when the request failed, the catch block called the winston print the error in the console, but the problem the request does not stopped, I tried to send a 500 code it doesn't work(here's a screenshot of postman when catch block is called).
My question now is, How I can send 500 code error, and stop the request process at the same time.?
Upvotes: 0
Views: 440
Reputation: 8515
Try with
res.sendStatus(500);
instead of
res.status(500);
The latter only sets the statusCode
property of the Response but it's not sending anything
Upvotes: 1