So in my MERN project in my router, I am trying to send some data so I can get afterwards on my react component so I can use that data.
But I get this error when I run my code: TypeError: Cannot read property 'status' of undefined
Here is my code:
const Accomodation = require('../models/accomodation')
Accomodation.findOne({email: req.session.passport.user}).lean().exec((err, user, res) => {
if (err) {
console.log(err, null);
}
if (user) {
res.status(200).send({
message: user.accomcate
})
}
})
});