GET by ID
Wed Jun 23 2021 14:31:37 GMT+0000 (Coordinated Universal Time)
Saved by
@joeavargas
// GET - READ A SPECIFIC PRODUCT BASED ON ID
app.get('/api/read/:id', (req, res) =>{
(async () => {
try{
const document = db.collection('products').doc(req.params.id);
let product = await document.get();
let response = product.data()
// Successfully queried data
return res.status(200).send(response);
}
catch(error){
// Handle error
console.log(error);
return res.status(500).send(error);
}
})();
});
content_copyCOPY
Comments