I want to re-render a jade from node.js to set an errormessage. I get the Error "Can't set headers after they are sent".
This is my Code...
app.post('/login', function (req, res) {
checkUserAndPassword(req.body.mail, req.body.password, function (status) {
console.log(status);
if (status === 1) {
getInstances(function (instances) {
res.render('mainSite', {title: "Systemverwaltung - Übersicht", instances: instances});
});
} else {
res.render('index', {title: "Systemverwaltung", error: "Wrong Mail or Password!"});
}
});
});
Has anyone an idea?