MCPcopy
hub / github.com/Open-Legal-Products/mike / apiRequest

Function apiRequest

frontend/src/app/lib/mikeApi.ts:72–97  ·  view source on GitHub ↗
(path: string, init?: RequestInit)

Source from the content-addressed store, hash-verified

70}
71
72async function apiRequest<T>(path: string, init?: RequestInit): Promise<T> {
73 const authHeaders = await getAuthHeader();
74 const { headers: initHeaders, ...restInit } = init ?? {};
75 const response = await fetch(`${API_BASE}${path}`, {
76 cache: "no-store",
77 ...restInit,
78 headers: {
79 Accept: "application/json",
80 ...authHeaders,
81 ...(initHeaders as Record<string, string> | undefined),
82 },
83 });
84
85 if (!response.ok) {
86 throw await toApiError(response, path);
87 }
88
89 if (
90 response.status === 204 ||
91 response.headers.get("content-length") === "0"
92 ) {
93 return undefined as T;
94 }
95
96 return (await response.json()) as T;
97}
98
99async function apiBlobRequest(path: string): Promise<{
100 blob: Blob;

Callers 15

listProjectsFunction · 0.85
createProjectFunction · 0.85
deleteAccountFunction · 0.85
deleteAllChatsFunction · 0.85
deleteAllProjectsFunction · 0.85
deleteAllTabularReviewsFunction · 0.85
getUserProfileFunction · 0.85
updateUserProfileFunction · 0.85
updateUserMfaOnLoginFunction · 0.85
getApiKeyStatusFunction · 0.85
saveApiKeyFunction · 0.85
listMcpConnectorsFunction · 0.85

Calls 2

getAuthHeaderFunction · 0.85
toApiErrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…