I am looking how to fetch in JavaScript URLs which respond GZIP headers then parse the content to JSON. I have tried :
function fetchJson(url, callback = null, callbackError = null, unzip = false) {
fetch(url)
.then(r => {
if (unzip) r = atob(r);
return r.json();
})
.then(r => {
if (callback !== null) callback(r);
})
.catch(err => {
console.error(err);
if (callbackError !== null) callbackError();
});
};
But I get this error :
DOMException: String contains an invalid character