I am trying to create an api in my server.js file for a react app. I connected the server and as soon as I imported data.js and set it to the api/products page it gave me the error.
import express from 'express';
import data from '../src/data.js';
const app = express();
app.get('/api/products', (req, res) => {
res.send(data.products);
});
app.get('/', (req, res) => {
res.send('Server is ready');
});
app.listen(5000, () => {
console.log('Serve at http://localhost:5000');
});