Spaces:
Running
Running
Download frontend/src/api.ts from VAST-AI/Tripo-Simready-Explorer: direct link, hf CLI and curl.
- Browser
- Download file 828 Bytes
-
https://huggingface.co/spaces/VAST-AI/Tripo-Simready-Explorer/resolve/main/frontend/src/api.ts
- Command line
-
hf download hf://spaces/VAST-AI/Tripo-Simready-Explorer/frontend/src/api.ts
-
curl -L -o api.ts https://huggingface.co/spaces/VAST-AI/Tripo-Simready-Explorer/resolve/main/frontend/src/api.ts
828 Bytes
| import type { Catalog, Preview } from './types'; | |
| async function request<T>(url: string, signal?: AbortSignal): Promise<T> { | |
| const response = await fetch(url, { signal, headers: { Accept: 'application/json' } }); | |
| if (!response.ok) { | |
| let message = `Request failed (${response.status})`; | |
| try { | |
| const body = await response.json(); | |
| message = typeof body.detail === 'string' ? body.detail : body.message || message; | |
| } catch { /* A proxy may return a non-JSON error page. */ } | |
| throw new Error(message); | |
| } | |
| return response.json() as Promise<T>; | |
| } | |
| export const getCatalog = (refresh = false) => request<Catalog>(`/api/catalog${refresh ? '?refresh=true' : ''}`); | |
| export const getPreview = (id: string, signal?: AbortSignal) => request<Preview>(`/api/assets/${encodeURIComponent(id)}/preview`, signal); | |