You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
everything has been going well as am building shopping cart, but when i click in product it says request failed with status code 404.
here is my server.js
`import express from 'express';
import data from './data.js';
everything has been going well as am building shopping cart, but when i click in product it says request failed with status code 404.
here is my server.js
`import express from 'express';
import data from './data.js';
const app = express();
app.get('/api/Products/:id', (req, res) => {
const product = data.products.find((x) => x._id === req.params.id);
if (product) {
res.send(product);
} else {
res.status(404).send({ message: 'Product Not Found' });
}
});
app.get('/api/products', (req, res) => {
res.send(data.products);
});
app.get('/', (req, res) => {
res.send('Server is ready');
});
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log(
Serve at http://localhost: ${port}
);});`
The text was updated successfully, but these errors were encountered: