I know correctly that I wrapped it entirely in a big if else, because I have several res.render functions.
How can I do something like this that should prevent the rest of the route from completing:
if(req.params.url === undefined){ res.render('layout'); return; }
OR
if(req.params.url === undefined){ res.render('layout'); next(); }
But both of them execute the rest of the code below them, which have already sent headers.
Now my code is as follows:
exports.activate = function(req, res){ var hash = req.params.hash; if(hash === undefined){ res.render('activation'); next(); } else { // Do stuff with hash res.render('activateOne', {hash: hash}); } }
source share