I am querying a user in a friend request array which works, but the check which I am using userAdd for keeps showing up as undefined. Anyone know why it is showing up as undefined?
This is the code:
    exports.searchPost = function(req, res, err) {
    User.find({$or:[
            {firstName: req.body.firstName},
            {lastName: req.body.lastName},
            {email: req.body.email},
            {phone: req.body.phone}]
    }, function(err, users) {
        if(err) {
            return res.render('searchError', {title: 'Weblio'}); 
        } else {
            if(req.body.firstName=== '' && req.body.lastName==='' && req.body.email==='' && req.body.phone=== '') {
                //maybe  a diff page saying that is not a valid search page
                return res.render('searchError', {title: 'Weblio'});        
            } else {
                    var userAdd;
                    console.log('addman');
                    users.forEach(function(user)  {
                        User.findById(req.signedCookies.userid, 
                            {friendRequest: user._id}, function() {
                                if(user._id === true ) {
                                    console.log('addman1'); 
                                    return userAdd = true;
                                } else {
                                    console.log('addman2');
                                    return userAdd = false;
                                    console.log(user._id);  
                                }
                            })
                        }); 
                    console.log(userAdd);
                return res.render('searchResults', {title: 'Weblio',        
                    usersFound: users, 
                    userAdded: userAdd
                });
            } 
        }
    });
};
 
    