这是我的更改密码功能,当此功能被邮递员击中时起作用,但是当我尝试从应用程序中击中其给出错误时>]
async function changePassword(req,res) { try { email = req.user.email; let user = await userModel.findOne({email: email}); console.log(req.body.password+"dsddsd"); console.log(req.body.oldPassword); if(!bcrypt.compareSync(req.body.oldPassword, user.password)) { res.status(400).json({message : "Invalid Old Password"}); } else { req.body.password = bcrypt.hashSync(req.body.password, 10); try { await userModel.updateOne({email : email },{ $set : { password : req.body.password } }); res.status(200).json({message : "Password Changed SuccessFully"}); } catch (error) { res.status(500).json({message : "Something Went Wrong"}); } } } catch (error) { res.status(500).json({message : "Error"}); } };
在位置0的JSON中获取错误的意外令牌o
这是我的更改密码功能,当此功能被邮递员使用时起作用,但是当我尝试从应用程序中访问它时,它给出了错误异步功能changePassword(req,res){试试{...