Skip to content Skip to sidebar Skip to footer

Async Series Responds With False, When It Should Be True

Hey so I am using an async series to create an array with the user found in a search result to loop through and see if they are part of the friend request array of the user logged

Solution 1:

I think there are a couple of issues where you check if (user._id === true) {.

The first issue is that your expecting user._id to be a Boolean - which it probably isn't. A simple if (user._id) { will check if it's a "truthy" value - which all numbers except 0 are.

However, I think there may be a second issue there: that user variable is from your users.forEach(function (user) { - I'm guessing that you actually want to be checking the results of your User.findById(req.signedCookies.userid, {friendRequest: user._id} function(... code. In that case you need to add error, user2 parameters to the callback function or something along those lines.

Post a Comment for "Async Series Responds With False, When It Should Be True"