Complete ExpressJS Request

How do I end an Express 3 request? res.end (), of course, does not stop processing.

exports.home = function(req, res) {
  res.end();
  console.log('Still going, going...');
+5
source share
1 answer

You need to return. For instance.

exports.home = function(req, res) {
  return res.end();
  console.log('I will never run...');

res.end()just terminates and discards the response to the client. Like any other action, however, this does not mean that JavaScript stops working, so we need to explicitly returnexit the function (although I can ask you why you will have code after repeating the answer, t really want to run .. .?).

+6
source

All Articles