PUT

PHOTO EMBED

Wed Jun 23 2021 14:54:03 GMT+0000 (UTC)

Saved by @joeavargas

// PUT (Update)
app.put('/api/update/:id', (req, res) =>{

    (async () => {

        try{
            const document = db.collection('products').doc(req.params.id);

            await document.update({
                name: req.body.name,
                description: req.body.description,
                price: req.body.price

            });
          // Successfully updated document
            return res.status(200).send(response);
        }
        catch(error){
          // Handle error
            console.log(error);
            return res.status(500).send(error);
        }
    })();
}); 
content_copyCOPY