POST
Wed Jun 23 2021 14:16:20 GMT+0000 (Coordinated Universal Time)
Saved by
@joeavargas
// POST (Create)
app.post('/api/create', (req, res) =>{
(async () => {
try{
// Create and send the JSON object to the db to a collection called "products"
await db.collection('products').doc('/' + req.body.id + '/')
.create({
name:req.body.name,
description: req.body.description,
price: req.body.price
})
// Successfully created document
return res.status(200).send();
}
catch(error){
// Handle error
console.log(error);
return res.status(500).send(error);
}
})();
});
content_copyCOPY
Comments