hello I am trying to replicate the code of a course to create a social network with JS Angular and mongo DB the problem is that I am stuck in the following line of code:
}
// Get data from a user
function getUser (req, res) {
var userId = req.params.id;
User.findById (userId, (err, user) => {
if (err) return res.status (500) .send ({message: 'Error in the request'});
if (! user) return res.status (404) .send ({message: 'The user does not exist'});
followThisUser (req.user.sub, userId) .then ((value) => {
return res.status (200) .send ({user, value});
});
});
}
async function followThisUser (identity_user_id, user_id) {
var following = await Follow.findOne ({"user": identity_user_id, "followed": user_id}). exec ((err, follow) => {
if (err) return handleError (err);
return follow;
});
var followed = await Follow.findOne ({"user": user_id, "followed": identity_user_id}). exec ((err, follow) => {
if (err) return handleError (err);
return follow;
});
return {
following: following
followed: followed
};
}
Does not return the Following or Followed when I run the api in Postman, can you tell me what I'm doing wrong?