为什么尝试调用此方法时promise会导致错误:llegal arguments: function string
,
const changePassword = function(context, user, newPass){
return new Promise(async (resolve, reject) => {
try {
hash = bcrypt.hashSync(newPass, 10);
const result = await context.db("users").where('id', user.id).update({
password: hash,
old_passwod: user.password
});
resolve("Senha alterada");
} catch (err){
reject(new Error('Não foi possivel alterar a senha! '+err));
}
});
发生什么事了?
发布于 2020-07-27 11:46:01
我尝试删除异步,但同样的错误。
const changePassword = function(context, user, novaSenha){
return new Promise((resolve, reject) => {
try {
hash = bcrypt.hashSync(novaSenha, 10);
const result = context.db("users").where('id', user.id).update({
password: hash,
old_passwod: user.password
});
resolve("Senha alterada");
} catch (err){
reject(new Error('Não foi possivel alterar a senha! '+err));
}
});
}
https://stackoverflow.com/questions/63108051
复制相似问题