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
res
object 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
.