Trying to fetch json data from local file and keep getting
"JSON.parse: unexpected end of data at line 1 column 1" .
I have tried numerous parameters to the fetch function but I keep getting at least 1 error.
function getData() {
fetch('./data.json', {mode: 'no-cors'})
.then((res) => res.json())
.then((data) => {
console.log(data);
})
};
JSON Data
{
"CustomerJohn": [
{
"month": "April",
"transaction": 1,
"price": 57
},
{
"month": "April",
"transaction": 2,
"price": 89
},
{
"month": "May",
"transaction": 1,
"price": 163
},
{
"month": "May",
"transaction": 2,
"price": 43
},
{
"month": "May",
"transaction": 3,
"price": 221
},
{
"month": "June",
"transaction": 1,
"price": 99
},
{
"month": "June",
"transaction": 2,
"price": 201
}
]
}
I would like to console.log the data to make sure it if functioning properly.