NodeJS “message”:“User.findOne(...).lean.exec is not a function”}在YouTube的MERN课程中

vjhs03f7  于 11个月前  发布在  Node.js
关注(0)|答案(1)|浏览(81)

userController.js中的这行代码有错误:

const duplicate = await User.findOne({ username }).lean.exec();

字符串
在Postman中,它会转到“message”:“User.findOne(...).lean.exec不是函数”}
只需将上面的代码替换为(我忘记了括号..):

// Check if user exists, if there is duplicates
const duplicate = await User.findOne({ username }).lean().exec();

sg24os4d

sg24os4d1#

问题出在。lean后面缺少括号
它应该是.lean().exec()

相关问题