also use cached response for server errors

This commit is contained in:
2025-01-26 16:50:37 +00:00
parent 32e8cc8054
commit e7ba689f14
+6 -4
View File
@@ -67,12 +67,14 @@ export default class WebStorage {
}
}
}
return this.#fetch(resource, options).then(
response => {
return this.#fetch(resource, options)
.then(async response => {
if (response.status >= 500) {
throw new Error(response.statusText + '\n' + await response.text())
}
this.#cache.put(resource, response)
return response
},
error => {
}).catch(error => {
console.warn(error)
return this.#cache.match(resource)
}