* fetch the corresponding url object in response or stored object format * @param url url * @param storetype the storage type for indexedDB * @param signal an optional abort signal to abort fetching * @returns response in json, arraybuffer or pure response format
(url: string, storetype?: string, signal?: AbortSignal)
| 365 | * @returns response in json, arraybuffer or pure response format |
| 366 | */ |
| 367 | async fetchWithCache(url: string, storetype?: string, signal?: AbortSignal): Promise<any> { |
| 368 | await this.addToCache(url, storetype, signal); |
| 369 | const result = await this.cache.match(new Request(url)); |
| 370 | if (result === undefined) { |
| 371 | // Already called `addToCache()`, should expect the request in cache. |
| 372 | throw Error("Cannot fetch " + url); |
| 373 | } |
| 374 | return await this.responseTostoretype(result, storetype); |
| 375 | } |
| 376 | |
| 377 | async addToCache(url: string, storetype?: string, signal?: AbortSignal) { |
| 378 | const request = new Request(url, signal ? { signal } : undefined); |
nothing calls this directly
no test coverage detected