MCPcopy Create free account
hub / github.com/ImGoodBai/MapGoGoGo / request

Function request

frontend/src/api.ts:11–25  ·  view source on GitHub ↗
(path: string, init?: RequestInit)

Source from the content-addressed store, hash-verified

9const jsonHeaders = { "Content-Type": "application/json" };
10
11async function request<T>(path: string, init?: RequestInit): Promise<T> {
12 const res = await fetch(path, {
13 credentials: "include",
14 ...init,
15 headers: {
16 ...(init?.body ? jsonHeaders : {}),
17 ...(init?.headers || {}),
18 },
19 });
20 if (!res.ok) {
21 const text = await res.text();
22 throw new Error(text || `Request failed: ${res.status}`);
23 }
24 return (await res.json()) as T;
25}
26
27export const api = {
28 config: () => request<AppConfig>("/api/config"),

Callers 1

api.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected