controllers/userController.js
//PUT to update user by id
PUT to update user by id
PUT to update user by id
updateUser({ params, body }, res) {
          User.findOneAndUpdate(
               { _id: params.id }, 
               body, 
               { new: true, runValidators: true }
          )
          .then(dbUser => {
               if (!dbUser) {
                    res.status(404).json({ message: 'No user found with that id.' });
                    return;
               }
               res.json(dbUser);
          })
          .catch(err => res.json(err));
     }
updateUser ( { params , body } , res ) { User . findOneAndUpdate ( { _id : params . id } , body , { new : true , runValidators : true } ) . then ( dbUser => { if ( ! dbUser ) { res . status ( 404 ) . json ( { message : 'No user found with that id.' } ) ; return ; } res . json ( dbUser ) ; } ) . catch ( err => res . json ( err ) ) ; }
PUT to update user by id
PUT to update user by id