(path, fetchType)
| 9 | }; |
| 10 | |
| 11 | export function genericFetch(path, fetchType) { |
| 12 | const responseType = getResponseTypeFromFetchType(fetchType); |
| 13 | return fetch(path) |
| 14 | .then((r) => { |
| 15 | if (!r.ok) throw new Error(`${r.status} ${r.statusText} (${path})`); |
| 16 | return r[responseType](); |
| 17 | }) |
| 18 | .then((r) => { |
| 19 | if (fetchType === 'bytes') { |
| 20 | return new Uint8Array(r); |
| 21 | } |
| 22 | return r; |
| 23 | }); |
| 24 | } |
no test coverage detected