0

const userName = req.body.userNames; const password = req.body.password;

con.query("SELECT * FROM users where email = ? AND password = ?", [userName, password], function(err, collections){
    if(err){
        console.log(err);
    }
    else {
        if(collections != 0){
            res.render('userProfile', {collections: collections})
            console.log(collections);
    }
    else{
        res.jason("Incorrect password or Account does not exist, check your login again.. Thank you");
    }
}
});

And here is my handle bars view < li class = "nav-item dropdown header-img-icon" > < div class = "dropdown-menu" > {{#each collections}} {{collections.fullName}}

{{collections.email}}

{{/each}}

1 Answer 1

0

You shouldn't include collections as part of the Handlebars view when referencing the child variables:

{{#each collections}}
  {{fullName}}
  {{email}}
{{/each}}

Also, I don't think the if(collections != 0) code is doing what you expect:

if(collections.length > 0) {
  ...
}
Sign up to request clarification or add additional context in comments.

2 Comments

okay i get i now, since its a single record there isnt a need to loop empty fields. Thank you it worked
Please mark as accepted, if it solves your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.