having some trouble figuring out why I get this error.
I have tried changing syntax but dont get it right, please help.
I think this is just a syntaxerror.
this is how i send my data
const data = { newPassword : newPassword }
const response = await request({ endpoint: `blablabla`, method: "PUT", body: data }
this is how i receive the data
const {newPassword} = req.body;
if(token && newPassword) {
console.log("token and password exist");
User.findOne({token: token}).then(user=> {
console.log("password" + newPassword); //prints out correct password
user.password = newPassword;
user.usertoken = "";
user.save(function(err){
if(err)return next(err);
else res.json({message:"Password changed",result:true})
});
}).catch(next)
}
else {
res.status(400).json({message:"Missing information! The password could not be updated.",result:false})
}