I am using ExpressJS and NodeJS. I am trying to load a json file from my server as a test. The json file is in the same location as the javascript file that is trying to read the json file but it says it cannot find the file even when i used relative path.
fs.readFile('./customers.json', 'utf8', (err, data) => {
if (err) {
console.log("ERROR: " + err);
} else {
jsonData = JSON.parse(data);
res.json(data);
}
});
The error i get when i go to localhost:3000/customers
:
[0] ERROR: Error: ENOENT: no such file or directory
Am i using the wrong path i am a bit confused what is wrong here since they are both in the same folder: