//send all data from a file to frontend
app.get('/', (req, res) =>{
// res.json([{name: 'asfand'},{name: 'saad'}])
const newproducts = products.map((product) =>{
const {id, name, image} = product;
return{id, name , image}
})
res.json(newproducts)
// res.json(products)
})
//send only one (find by id)
app.get('/', (req, res) =>{
const singleproduct = products.find((product) => product.id ===1)
res.json(singleproduct)
})