Compare commits

...

3 Commits

Author SHA1 Message Date
Harel M 28498d57f8 Apply suggestions from code review 2024-09-30 10:07:18 +03:00
Harel M 317448dc3f Update changelog 2024-09-29 13:13:37 +00:00
Harel M 14391212bf Fix network issue 2024-09-29 13:08:49 +00:00
2 changed files with 9 additions and 4 deletions
+2
View File
@@ -7,6 +7,8 @@
- _...Add new stuff here..._
### 🐞 Bug fixes
- Fix incorrect handing of network error response (#944)
- _...Add new stuff here..._
## 2.1.1
+7 -4
View File
@@ -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)
})
}