Reputation: 131
Apparently in Express 4.7.2 render does not explicit ends the execution, that means:
on Express 4.2
res.render('path/to/view');
res.render('path/to/view');
Render display the first view and ends the execution.
on Express 4.7.2
res.render('path/to/view');
res.render('path/to/view');
Throws 'Can't set headers after they are sent' error, for example:
app.get('/path', function(req, res) {
if ( someFancyValidation ) {
res.render('error_view');
}
res.render('succes_view');
});
We need an explicit 'return' statement in order to get the desirable result.
Upvotes: 0
Views: 97
Reputation: 3744
It should be
app.get('/path', function(req, res) {
if ( someFancyValidation ) {
res.render('error_view');
}
else//you missed this
res.render('succes_view');
});
You can't render twice for a single call.
Upvotes: 1