0

So this is my code

router.put('/update/:year', async (req, res) => {
  const year = req.params.year;
    World.findByIdAndUpdate(year, req.body, {new:true})
    .then(data => {
      if (!data) {
        res.status(404).send({
          message: `Cannot update Tutorial with id=${year}. Maybe Tutorial was not found!`
        });
      } else {


        res.send({ message: "Tutorial was updated successfully." })};
    })
    .catch(err => {
      res.status(500).send({
        message: "Error updating Tutorial with year=" + year
      });
    });
})

This code returns a success message when I run it on Postman, but my data isn't updating

Postman screenshot

enter image description here

1 Answers1

0
World.findByIdAndUpdate(_id, { year: 2000 }, {new:true})