Skip to content

Commit

Permalink
Fix network issue
Browse files Browse the repository at this point in the history
  • Loading branch information
HarelM authored Sep 29, 2024
1 parent 6089cde commit 1439121
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libs/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ function loadJSON(url: string, defaultValue: any, cb: (...args: any[]) => void)
mode: 'cors',
credentials: "same-origin"
})
.then(function(response) {
.then((response) => {
if (!response.ok) {
throw new Error('Failed to load metadata for ' + url);
}
return response.json();
})
.then(function(body) {
.then((body) =>{
cb(body)
})
.catch(function() {
console.warn('Can not metadata for ' + url)
.catch(() =>{
console.warn('Can not load metadata for ' + url + ', using default value ' + defaultValue);
cb(defaultValue)
})
}
Expand Down

0 comments on commit 1439121

Please sign in to comment.