I would like to know if these two different approach is it identical in expressjs?
res.statusCode = 500;
return res.json({
status: "error"
});
or
return res.status(500).json({
status: "error"
});
the
resobject is an enhanced version of Node’s own response object and supports all built-in fields and methods.
Sets the HTTP status for the response. It is a chainable alias of Node’s response.statusCode.
So the result is the same. expressjs just added a chainable version of statusCode.
Multiple status codes like status code 200, 404, and 500 in the same code? 200 for success, 404 for no data matching.