Turqus
Turqus

Reputation: 117

Printing out errors in EJS

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

Answers (1)

user8574315
user8574315

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

Related Questions