title: How do I update data without reloading mongodb expressjs react
body: <p>So I want to update my data on the client-side without reloading, But I don't know how to.</p>
  <p>here is my front end code</p>
  <pre><code>const handleStockUp = event =&gt; {
         const oldQuantity = item.quantity;
         const newQuantity = event.target.quantity.value;
         const quantity = Number(oldQuantity) + Number(newQuantity);
            console.log(quantity)
              event.preventDefault()
              const updatedQuantity = { quantity };
              const url = `http://localhost:5000/item/${itemId}`;
              fetch(url, {
                  method: 'PUT',
                  headers: {
                      'content-type': 'application/json'
                  },
                  body: JSON.stringify(updatedQuantity)
              })
                  .then(res =&gt; res.json())
                  .then(data =&gt; {
                      event.target.reset();
                  })
          }
      
      &lt;form onSubmit={handleStockUp}&gt;
          &lt;input type=&quot;number&quot; name=&quot;quantity&quot; /&gt;
          &lt;button type=&quot;submit&quot; className=&quot;btn btn-primary&quot; name=&quot;stock&quot; &gt;StockUp&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  <p>So You Like put a number in the input field then press the button it should update the quantity but you have to reload to check it. and the backend Code</p>
  <pre><code>app.put('/item/:id', async (req, res) =&gt; {
          const id = req.params.id;
          const updatedQuantity = req.body;
          const filter = { _id: ObjectId(id) };
          const options = { upsert: true };
          const updatedDoc = {
              $set: {
                  quantity: updatedQuantity.quantity
              }
          };
          const result = await computerCollection.updateOne(filter, updatedDoc, options);
          res.send(result);
      });
  </code></pre>
  <p>Please Tell me if you know how to solve if :)</p>