How would I end an Express 3 request? res.end() certainly doesn't stop the processing.
exports.home = function(req, res) {
res.end();
console.log('Still going, going...');
You'll need to return
. E.g.,
exports.home = function(req, res) {
return res.end();
console.log('I will never run...');
res.end()
simply completes and flushes the response to the client. Just like any other action, however, that doesn't tell JavaScript to stop running so we need to explicitly return
out of the function (although I might ask the question of why you would have code after flushing the response that you don't actually want to run...?).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With