Wednesday, 26 April 2017

ES6 function declaration behaves differently from vanilla JS [duplicate]

UserSchema.methods.verifyPassword = (password, cb) => {
    bcrypt.compare(password, this.password, (err, isMatch) => {
        if (err) return cb(err)
        cb(null, isMatch)
    })
}

Returns "Incorrect arguments" when using the method while

UserSchema.methods.verifyPassword = function(password, cb) {
    bcrypt.compare(password, this.password, (err, isMatch) => {
        if (err) return cb(err)
        cb(null, isMatch)
    })
}

Works as expected....

Am I declaring the function for the method wrong?



via mikethehud

No comments:

Post a Comment