MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / call

Function call

ui/src/lib/adapter.ts:312–337  ·  view source on GitHub ↗
(path: string, init: RequestInit, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

310 globalThis.fetch(...args));
311
312 async function call<T>(path: string, init: RequestInit, signal?: AbortSignal): Promise<T> {
313 let response: Response;
314 try {
315 response = await doFetch(`${base}${path}`, { ...init, signal });
316 } catch (cause) {
317 if (signal?.aborted) throw cause;
318 throw new ApiFailure(
319 0,
320 'unreachable',
321 'The codegraph ui server is not answering.',
322 'It may have been stopped — restart it with `codegraph ui` and reload this page.'
323 );
324 }
325
326 const body = (await response.json().catch(() => null)) as unknown;
327 if (!response.ok) {
328 const failure = (body as ApiErrorBody | null) ?? {};
329 throw new ApiFailure(
330 response.status,
331 failure.code ?? 'error',
332 failure.error ?? `The server answered ${response.status}.`,
333 failure.hint ?? null
334 );
335 }
336 return body as T;
337 }
338
339 function getJson<T>(path: string, signal?: AbortSignal): Promise<T> {
340 return call<T>(path, { headers: { accept: 'application/json' } }, signal);

Callers 3

getJsonFunction · 0.70
writeFunction · 0.70
callHostMethod · 0.50

Calls 1

jsonMethod · 0.65

Tested by

no test coverage detected