({
url,
options,
fallback,
}: {
url: string;
options?: RequestInit;
fallback: T;
})
| 55 | } |
| 56 | |
| 57 | public async fetchWithSafeDefaults<T>({ |
| 58 | url, |
| 59 | options, |
| 60 | fallback, |
| 61 | }: { |
| 62 | url: string; |
| 63 | options?: RequestInit; |
| 64 | fallback: T; |
| 65 | }): Promise<T> { |
| 66 | const data = await this.fetchWithDefaults<T>(url, options); |
| 67 | if (!data) { |
| 68 | console.error(url, " response is empty"); |
| 69 | return fallback; |
| 70 | } |
| 71 | |
| 72 | if (typeof data === "string") { |
| 73 | console.error(url, " response is string"); |
| 74 | return fallback; |
| 75 | } |
| 76 | |
| 77 | return data; |
| 78 | } |
| 79 | |
| 80 | getToolVersion = async () => { |
| 81 | return await this.fetchWithDefaults("/status"); |
no outgoing calls
no test coverage detected