Error: data and salt arguments required

前端 未结 3 1946
野性不改
野性不改 2020-12-17 16:02

I am trying to save a user to mongodb database using post request as follow, but I got the error bcrypt Error: data and hash arguments required .It\'s a pretty simple set up

3条回答
  •  情歌与酒
    2020-12-17 16:24

    Per mongoose docs: https://mongoosejs.com/docs/faq.html

    Q. I'm using an arrow function for a virtual, middleware, getter/setter, or method and the value of this is wrong.

    A. Arrow functions handle the this keyword much differently than conventional functions. Mongoose getters/setters depend on this to give you access to the document that you're writing to, but this functionality does not work with arrow functions. Do not use arrow functions for mongoose getters/setters unless do not intend to access the document in the getter/setter.

提交回复
热议问题