I have a async function with a fetch call to an api , in Safari the function works fine with no errors, but in Chrome and Firefox I get the following error:
"SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"
I think it has something to do with the json response not being readable, but I was not sure how to fix this inside of the following function :
async function getUserTracks() {
try {
await fetch("https://www.soundpro.city/music/music_all/?format=json")
.then(res => res.json())
.then(data => {
for (item of data)
trackNames.push(item['title']),
trackUrl.push(item['track']),
albums.push(item['artist_name'])
})
} catch(error) {
console.log(error)
}
}
getUserTracks();
console.log(trackNames, trackUrl, albums);