node sent error with status code code example
Example 1: express set response code
res.status(400);
res.send('None shall pass');
Example 2: error handling in node js
app.get('/', function (req, res, next) {
Promise.resolve().then(function () {
throw new Error('BROKEN')
}).catch(next) // Errors will be passed to Express.
})