Fix network issue

This commit is contained in:
Harel M
2024-09-29 13:08:49 +00:00
committed by GitHub
parent 6089cde302
commit 14391212bf
+7 -4
View File
@@ -5,14 +5,17 @@ function loadJSON(url: string, defaultValue: any, cb: (...args: any[]) => void)
mode: 'cors', mode: 'cors',
credentials: "same-origin" credentials: "same-origin"
}) })
.then(function(response) { .then((response) => {
if (!response.ok) {
throw new Error('Failed to load metadata for ' + url);
}
return response.json(); return response.json();
}) })
.then(function(body) { .then((body) =>{
cb(body) cb(body)
}) })
.catch(function() { .catch(() =>{
console.warn('Can not metadata for ' + url) console.warn('Can not load metadata for ' + url + ', using default value ' + defaultValue);
cb(defaultValue) cb(defaultValue)
}) })
} }