MCPcopy
hub / github.com/Zleap-AI/SAG / request

Function request

web/src/lib/api.ts:33–49  ·  view source on GitHub ↗
(url: string, init?: RequestInit)

Source from the content-addressed store, hash-verified

31}
32
33async function request<T>(url: string, init?: RequestInit): Promise<T> {
34 const headers = new Headers(init?.headers);
35 if (init?.body != null && !headers.has("Content-Type")) {
36 headers.set("Content-Type", "application/json");
37 }
38 const response = await fetch(url, {
39 ...init,
40 headers
41 });
42 const text = await response.text();
43 const data = safeParseJson(text);
44 if (!response.ok) {
45 const message = data?.error?.message ?? `请求失败:${response.status}`;
46 throw new Error(message);
47 }
48 return data as T;
49}
50
51export const api = {
52 async listProjects(includeArchived = false) {

Callers 15

listProjectsFunction · 0.85
createProjectFunction · 0.85
updateProjectFunction · 0.85
archiveProjectFunction · 0.85
restoreProjectFunction · 0.85
deleteProjectFunction · 0.85
listDocumentsFunction · 0.85
getProjectStatsFunction · 0.85
getProjectGraphFunction · 0.85
getDocumentFunction · 0.85
listChunksFunction · 0.85
listEventsFunction · 0.85

Calls 1

safeParseJsonFunction · 0.85

Tested by

no test coverage detected