MCPcopy Index your code
hub / github.com/huggingface/ml-intern / apiFetch

Function apiFetch

frontend/src/utils/api.ts:31–50  ·  view source on GitHub ↗
(
  path: string,
  options: RequestInit = {}
)

Source from the content-addressed store, hash-verified

29
30/** Wrapper around fetch with credentials and common headers. */
31export async function apiFetch(
32 path: string,
33 options: RequestInit = {}
34): Promise<Response> {
35 const headers = new Headers(options.headers);
36 const isFormData = options.body instanceof FormData;
37 if (!isFormData && !headers.has('Content-Type')) {
38 headers.set('Content-Type', 'application/json');
39 }
40
41 const response = await fetch(path, {
42 ...options,
43 headers,
44 credentials: 'include', // Send cookies with every request
45 });
46
47 await handleUnauthorized(response);
48
49 return response;
50}
51
52function headersFromXhr(rawHeaders: string): Headers {
53 const headers = new Headers();

Callers 15

patchPolicyFunction · 0.90
SessionChatFunction · 0.90
WelcomeScreenFunction · 0.90
AppLayoutFunction · 0.90
trackHealthProClickFunction · 0.90
SessionSidebarFunction · 0.90
sendFeedbackFunction · 0.90
trackProClickFunction · 0.90
ChatInputFunction · 0.90
handleSelectModelFunction · 0.90
ExpiredBannerFunction · 0.90
InlineApprovalFunction · 0.90

Calls 1

handleUnauthorizedFunction · 0.85

Tested by

no test coverage detected