I'm a beginner in using fetch API, I'm trying to fetch json data within react application but it keeps returning 500 (Internal Server Error) The react application is running under http://localhost:3000/
I'v already added proxy in package.json file:
"proxy": "http://localhost:3000"
Below is a sample json file data/greeting.json:
{
"time": "am",
"greeting": "Good morning"
}
caller.js file has a method to call json:
function getGreetings() {
fetch(`./data/greeting.json`, {
headers : {
"Content-Type": "application/json",
"Accept": "application/json"
}
})
.then((response) => response.json())
.then((messages) => {console.log("messages");});
}