I'm having trouble displaying errors from an incomplete form. In my array of objects, I want to iterate through and retrieve the errors, but it seems the list is currently empty. Upon debugging, it appears that the errors variable contains
[
{
email: "Enter a valid email in the format <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bcded3c5fcd9c4ddcd6d0cdc1d6dddd85d8d4d6">[email protected]</a>",
},
{
username: "Please enter a valid username",
},
]
pug file
.auth-head
h2 Sign Up Now.
p Begin by setting up your account
ul
each error in errors
each val,key in error
li= val
How I'm passing this information to the pug file
res.render("signup",{errors:req.flash('validationFailure')});
EDIT. I have made changes to the format of the errors being returned as a single object in the array @Barmar
updated pug file
.auth-head
h2 Sign Up Now.
p Begin by setting up your account
ul
each val,key in errors
li= val
Updated errors object.
[
{
email: "Enter a valid email in the format <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="41232e38012439202c312d246f222e2c">[email protected]</a>",
username: "Please enter a valid username",
},
]