Node js mongoose findviewbyid not working

Viewed 17
Seems to have problem

This code contain model controller class where I am unable to retreivie the id using findbyid. idk what seems to be the problem. I am creating a basic application where I need to show the details according to the login user.

MAKE INSTRUCTOR ERR  TypeError: Cannot read properties of undefined (reading '_id')





       const user = await User.findById(req.user._id).exec();
   
</code>


findById seems not to be working....
0 Answers
Related