Reputation: 117
I have problem with printing errors in EJS because when i use in ejs <%= errors %> I am directed to Error 404 not found. Can someone tell me how it print out?
req.checkBody('login', 'Login is required').notEmpty();
req.checkBody('password', 'Password is required').notEmpty();
var errors = req.validationErrors();
if (errors) {
console.log(errors)
res.render('index', {
errors: errors
});
Upvotes: 0
Views: 447
Reputation: 11
U need to initialize errors first. For example: res.render('index'),{errors: null});
in the get-method of the index page.
Upvotes: 1