(url: string, opts?: any)
| 64 | } |
| 65 | |
| 66 | export async function fetchJSON<T>(url: string, opts?: any): Promise<T> { |
| 67 | const res = await fetchURL(url, opts); |
| 68 | |
| 69 | if (res.status === 200) { |
| 70 | return res.json() as Promise<T>; |
| 71 | } |
| 72 | |
| 73 | throw new StatusError(`${res.status} ${res.statusText}`, res.status); |
| 74 | } |
| 75 | |
| 76 | export function removePrefix(url: string): string { |
| 77 | url = url.split("/").splice(2).join("/"); |