// 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);
}
})();
});
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter