So, I'm building a login form with express and ejs. When the password Is wrong, my goal is to display a message in the page where the form is. I'm trying to do this:
if(matchUser.password !== password){
res.render("index", { error: "Wrong password" })
}
But, i know that if i pass the same variable in other renders, for example, when the page loads, it would work. I'm try to validate in the ejs, like this:
<%= error ? error : "" %>
How can i display it conditionality only passing the variable in one place only?