I wanted to show errors in username validation, so in my mongodb I added a unique: true for nicknames, now in my create action I have
new User({ nick: req.body.name}).save(function(err, data){
if(err) {
err["dest"] = "index"; err["message"] = "user name taken";
return next(err);
} res.redirect('/chats')
and then in the end of my routes I have
app.use(function(err, req, res, next) { res.render(err.dest, err.message) });
I dunno if its a proper way to do it, all I want is to show the error message from the page the request came, the above works except the url stays at the form's action url,…