The error comes from the bcrypt.hash
method.
In your case, you have the following piece of code :
bcrypt.hash(newUser.password, salt , (err, hash) => { ... }
I think that your problem comes from the newUser.password
that must be empty (null
or undefined
). The error says data and salt arguments required
. It looks like your salt is correctly generated and you didn't check if newUser.password === undefined
, so here's my bet: somehow newUser.password
is undefined.
Also, you can check if the genSalt
method works fine by adding if(err) throw (err);
after calling it as you did for the bcrypt.hash
method.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…