'how to updata any data in database after sucessfully showing console?

As you can in the react (clint-side) code , i am trying increase/decrese of Quantity in database and UI. in this code i am sucessfully show quantity in console . but i don't show it my UI and database . Now what should i do ?

Server side (react)

const { register, handleSubmit } = useForm(); const onSubmit = (data, event) => { const url = https://nameless-dusk 43671.herokuapp.com/products/${productsId} fetch(url, { method: "PUT", headers: { 'content-type': "application/json" }, body: JSON.stringify(data) }) .then(res => res.json()) .then(result => { console.log(result) event.target.reset() } ) }

update item on clint side

    app.put('/products/:id', async (req, res) => {
        const id = req.params.id;
        const updateUser = req.body;
        const filter = { _id: ObjectId(id) }
        const options = { upsert: true };
        const updateDoc = {
            $set: {
                name: updateUser.name,
                email: updateUser.email,
            }
        }
        const result = await 
          ProductCollection.updateOne(filter, updateDoc, 
          options)
          res.send(result)
    })


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source