Issue
For Express.js 4.x I can’t find wether I should return the response (or next function) or not, so:
This:
app.get('/url', (req, res) => {
res.send(200, { message: 'ok' });
});
Or this:
app.get('/url', (req, res) => {
return res.send(200, { message: 'ok' });
});
And what is the difference?
Solution
You don’t. The (req, res)
signature tells express this is the last function in the chain, and it does not expect a return value from this function. You can add a return statement, but it don’t "do anything", beyond the JS engine performing some additional (but meaningless) overhead.