Hello I'm trying to replicate the code of a course to create a social network with JS Angular and mongo DB the problem is that I'm stuck in the following line of code:
}
//Conseguir datos de un usuario
function getUser(req, res){
var userId = req.params.id;
User.findById(userId, (err, user) => {
if(err) return res.status(500).send({message: 'Error en la peticion'});
if(!user) return res.status(404).send({message: 'El usuario no existe'});
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
};
}
I do not return the Following or Followed when I run the api in Postman, can you tell me what I'm doing wrong?