MCPcopy
hub / github.com/OpenBMB/UltraRAG / httpRequest

Function httpRequest

ui/frontend/src/shared/api/http.ts:43–67  ·  view source on GitHub ↗
(path: string, options: RequestOptions = {})

Source from the content-addressed store, hash-verified

41}
42
43export async function httpRequest<T>(path: string, options: RequestOptions = {}): Promise<T> {
44 const { method = "GET", body, headers, signal } = options;
45 const response = await fetch(buildApiUrl(path), {
46 method,
47 credentials: "include",
48 headers: {
49 ...DEFAULT_HEADERS,
50 ...headers,
51 },
52 body: body === undefined ? undefined : JSON.stringify(body),
53 signal,
54 });
55
56 if (!response.ok) {
57 let payload: ApiErrorPayload | null = null;
58 try {
59 payload = await parseResponse<ApiErrorPayload>(response);
60 } catch {
61 payload = null;
62 }
63 throw new ApiHttpError(response.status, payload, `Request failed: ${method} ${path}`);
64 }
65
66 return parseResponse<T>(response);
67}

Callers 15

testAiConnectionFunction · 0.90
chatWithAiFunction · 0.90
savePromptContentFunction · 0.90
createPromptFunction · 0.90
deletePromptFunction · 0.90
renamePromptFunction · 0.90
fetchBackgroundTaskFunction · 0.90
deleteBackgroundTaskFunction · 0.90
fetchKbFilesFunction · 0.90
deleteKbFileFunction · 0.90
syncMemoryToKbFunction · 0.90

Calls 2

buildApiUrlFunction · 0.85
parseResponseFunction · 0.85

Tested by

no test coverage detected