Spaces:
Runtime error
Runtime error
Download apps/web/src/api/client.ts from ClaraSu/llm-router: direct link, hf CLI and curl.
- Browser
- Download file 549 Bytes
-
https://huggingface.co/spaces/ClaraSu/llm-router/resolve/main/apps/web/src/api/client.ts
- Command line
-
hf download hf://spaces/ClaraSu/llm-router/apps/web/src/api/client.ts
-
curl -L -o client.ts https://huggingface.co/spaces/ClaraSu/llm-router/resolve/main/apps/web/src/api/client.ts
549 Bytes
| import { getToken, clearToken } from '@/lib/auth' | |
| export async function apiFetch(path: string, options: RequestInit = {}): Promise<Response> { | |
| const token = getToken() | |
| const res = await fetch(path, { | |
| cache: 'no-store', | |
| ...options, | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| ...(token ? { Authorization: `Bearer ${token}` } : {}), | |
| ...(options.headers as Record<string, string> | undefined ?? {}), | |
| }, | |
| }) | |
| if (res.status === 401) { | |
| clearToken() | |
| window.location.href = '/login' | |
| } | |
| return res | |
| } | |