bcrypt使用报错-No callback function was given

来源:互联网 发布:地暖品牌 知乎 编辑:程序博客网 时间:2024/06/07 07:01

使用bcrypt时遇到的报错

throw "No callback function was given".No Callback function was given

bcrypt.hash()需要4个参数,

hash(data, salt, progress, cb)
The documentation is unclear on this: it states that datasalt and cb are required, which implies that progress isn't, but without it you'll get the error.
Pass a null if you don't care about tracking progress:

bcrypt.hash(user.password, salt, null, function (err, hash) { ... })

6down voteaccepted

bcrypt.hash() requires 4 arguments:

hash(data, salt, progress, cb)

The documentation is unclear on this: it states that datasalt and cb are required, which implies that progress isn't, but without it you'll get the error.

Pass a null if you don't care about tracking progress:

bcrypt.hash(user.password, salt, null, function (err, hash) { ... })
0 0
原创粉丝点击