Solution :
I had faced the same Error in the past while I was trying to fetch data from the json file.
"SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"
So, I just checked my path of the json file which was found to be incorrect,
const mysearch = document.getElementById("mysearch");
const mymatchList = document.getElementById("mymatch-list");
//search the json data and filter
const mysearchStates = async mysearchText => {
const myres = await fetch('../state.json');
const mystates = await myres.json();
console.log(states);
}
mysearch.addEventListener('input', () => mysearchStates(mysearch.value));
That’s why I simply changed the path of my file as below:
const myres = await fetch('./state.json');
& to my surprise it gave me the array back as a result. I hope this resolved your issue.