NodeJS -API finden Daten mit ID
//nodejs api find data with id (pass id througn url)
app.get('/:productID',(req, res) =>{
// console.log(req);
// console.log(req.params);
const {productID} = req.params;
const singleProduct = products.find((product) => product.id ===Number(productID));
if(!singleProduct){
return res.status(404).send('Product not found')
}
res.json(singleProduct)
})
Embarrassed Elephant