Unable to render page after querying model.findOne

I am using this query and am positively getting a user but unable to render pages. How do I render the pages inside findOne() without getting errors or warnings?

This is my code:

    Company.findOne({'vaccine.name': req_url}, function(err, user){
        if(user){
            console.log('User Found: ', user.username);
        }
    return res.render('transaction');
    });

Answer

This is occurring because there are two return statements and the might already have been sending a render response. Try adding a else statement in the other res.render

Leave a Reply

Your email address will not be published. Required fields are marked *