title: Node JS Using Bcrypt.Hash- Password does not get hashed after updating
body: <p>I am trying to do a update function for user profiles on the password. I don't know why but the password get hashed perfectly when signing in. However when I set up the update function using route.put, the password does not get hashed. It is still a text when I check on Postman. I would like to hash the password when the users change their passwords in text type. Here is what I did in Routes / API</p>
  
  <pre><code>router.put("/:_id", (req, res) =&gt; {
  var update=req.body
  const { errors, isValid } = validateEditProfile(req.body);
  
  if (!isValid) {
  return res.status(400).json(errors)
  }
  
  User.findByIdAndUpdate(req.params._id, update, { new: true })
  
  .then(user =&gt;res.json(user))
  .catch(err =&gt; res.status(404).json({ update: false }));
  });
  </code></pre>
  
  <p>I have also added some line to hash password but it is still not working.</p>
  
  <pre><code>router.put("/:_id", (req, res) =&gt; {
  var update=req.body
  const { errors, isValid } = validateEditProfile(req.body);
  
  if (!isValid) {
  return res.status(400).json(errors)
  }
  var newPassword = req.body.password
  bcrypt.hash(newPassword,(hash)=&gt;{
  req.body.password=hash
  })
  User.findByIdAndUpdate(req.params._id, update, { new: true })
  
  .then(user =&gt;res.json(user))
  .catch(err =&gt; res.status(404).json({ update: false }));
   });
  </code></pre>