MCPcopy Index your code
hub / github.com/komodorio/helm-dashboard / fetchWithDefaults

Method fetchWithDefaults

frontend/src/API/apiService.ts:26–55  ·  view source on GitHub ↗
(
    url: string,
    options?: RequestInit
  )

Source from the content-addressed store, hash-verified

24 };
25
26 public async fetchWithDefaults<T>(
27 url: string,
28 options?: RequestInit
29 ): Promise<T | string> {
30 let response;
31
32 if (this.currentCluster) {
33 const headers = new Headers(options?.headers);
34 if (!headers.has("X-Kubecontext")) {
35 headers.set("X-Kubecontext", this.currentCluster);
36 }
37 response = await fetch(url, { ...options, headers });
38 } else {
39 response = await fetch(url, options);
40 }
41
42 if (!response.ok) {
43 const error = await response.text();
44 throw new Error(error);
45 }
46
47 const contentType = response.headers.get("Content-Type") || "";
48 if (!contentType) {
49 return {} as unknown as T;
50 } else if (contentType.includes("text/plain")) {
51 return await response.text();
52 } else {
53 return (await response.json()) as T;
54 }
55 }
56
57 public async fetchWithSafeDefaults<T>({
58 url,

Callers 15

ApiServiceClass · 0.95
resetCacheFunction · 0.80
UninstallFunction · 0.80
useDiffDataFunction · 0.80
useUpdateRepoFunction · 0.80
useDeleteRepoFunction · 0.80
useChartRepoValuesFunction · 0.80
useGetReleaseManifestFunction · 0.80
useGetReleaseInfoByTypeFunction · 0.80
useGetDiffFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected