title: How to update value with Axios from the front-end side to a MongoDB database?
body: <p>I have a list of employees and I try to build a method which makes it possible to change the value of the salary of a person from the front-end side. In the front-end side I have an input field where the user can write the new salary and near that I have an update button and when clicking it, it should update the value to the mongodb database. This is what I have so far:</p>
  <p>The code that I have in my node backend for updating the salary:</p>
  <pre><code>router.put('/:postId', async (req, res) =&gt; {
      try {
          const updatePost = await Post.updateOne({_id: req.params.postId}, { $set: {salary: req.body.salary}})
          res.json(updatePost);
      } catch (err) {
          res.json({ message: err });
      }
  });
  </code></pre>
  <p>The state of the upcoming new salary and the function that is added to the update buttons onClick when the user wants to update the new salary to the database:</p>
  <pre><code>const [newSalary, setNewSalary] = useState(0);
  
  const updateEmployeeSalary = (postId) =&gt; {
      Axios.put('http://localhost:3000/posts/:postId', {salary: newSalary, id: postId}).then((response) =&gt; {
        alert('updated');
      });
    };
  </code></pre>
  <p>This is the input field and the button which I have in the website. These should trigger the updating of the salary:</p>
  <pre><code>&lt;input type=&quot;text&quot; placeholder=&quot;2000&quot; onChange={(event) =&gt; (setNewSalary(event.target.value))} /&gt;
  &lt;button onClick={() =&gt; {updateEmployeeSalary(val.postId)}}&gt;Update&lt;/button&gt;
  </code></pre>
  <p>The backend side of the code works as it updates the salary to the database when I do it from Postman. But how do I make it work so that the updating works directly from the website? I would really appreciate any tips and solutions!</p>