Reputation: 249
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
})
}
})
});
Upvotes: 1
Views: 41
Reputation: 572
.exec
accepts two arguments err
and res
, you are using three which is causing the error.
Upvotes: 1