TypeError:无法读取MERN中未定义的属性“发送”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TypeError:无法读取MERN中未定义的属性“发送”相关的知识,希望对你有一定的参考价值。

因此,在路由器的MERN项目中,我试图发送一些数据,以便以后可以在我的react组件上使用,以便可以使用该数据。

但是运行代码时出现此错误:TypeError: Cannot read property 'status' of undefined

这是我的代码:

  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
          })
      }
    })

});
答案

[.exec接受两个参数errres,您正在使用三个导致错误的参数。

以上是关于TypeError:无法读取MERN中未定义的属性“发送”的主要内容,如果未能解决你的问题,请参考以下文章