MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / api

Function api

ai-code-studio/src/app/helpers.ts:10–25  ·  view source on GitHub ↗
(path: string, init?: Omit<RequestInit, 'body'> & { body?: unknown })

Source from the content-addressed store, hash-verified

8} from './types';
9
10export async function api<T>(path: string, init?: Omit<RequestInit, 'body'> & { body?: unknown }) {
11 const response = await fetch(path, {
12 ...init,
13 headers: {
14 'content-type': 'application/json',
15 ...(init?.headers || {}),
16 },
17 body: init?.body ? JSON.stringify(init.body) : undefined,
18 });
19
20 const payload = (await response.json().catch(() => ({}))) as T & { error?: string };
21 if (!response.ok) {
22 throw new Error(payload.error || `请求失败:${response.status}`);
23 }
24 return payload;
25}
26
27export function formatRelativeTime(value?: number | string | null) {
28 if (!value) return '';

Callers 15

loadInitialStateFunction · 0.90
handleSaveConfigFunction · 0.90
handleRenameSessionFunction · 0.90
confirmDeleteSessionFunction · 0.90
handleSendFunction · 0.90
handleStopFunction · 0.90
handleApprovePendingRunFunction · 0.90
handleRejectPendingRunFunction · 0.90
handleClearQueueFunction · 0.90
handleResetFunction · 0.90
handleRefreshSessionsFunction · 0.90
handleSelectSessionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected