also use cached response for server errors
This commit is contained in:
@@ -67,12 +67,14 @@ export default class WebStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.#fetch(resource, options).then(
|
return this.#fetch(resource, options)
|
||||||
response => {
|
.then(async response => {
|
||||||
|
if (response.status >= 500) {
|
||||||
|
throw new Error(response.statusText + '\n' + await response.text())
|
||||||
|
}
|
||||||
this.#cache.put(resource, response)
|
this.#cache.put(resource, response)
|
||||||
return response
|
return response
|
||||||
},
|
}).catch(error => {
|
||||||
error => {
|
|
||||||
console.warn(error)
|
console.warn(error)
|
||||||
return this.#cache.match(resource)
|
return this.#cache.match(resource)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user