Files
OpenJarvis/frontend/src/api/client.ts
T
Jon Saad-FalconandClaude Opus 4.6 759efb9fa8 Add frontend CI workflow, error boundary, and VITE_API_URL support
- .github/workflows/frontend.yml: type-check + build on push/PR
- ErrorBoundary component wraps App with catch + retry UI
- API client reads VITE_API_URL env var for non-same-origin deploys
- vite-env.d.ts declares ImportMetaEnv type

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:02:09 +00:00

23 lines
819 B
TypeScript

import type { ModelInfo, SavingsData, ServerInfo } from '../types';
const BASE = import.meta.env.VITE_API_URL || ''; // relative to same origin by default
export async function fetchModels(): Promise<ModelInfo[]> {
const res = await fetch(`${BASE}/v1/models`);
if (!res.ok) throw new Error(`Failed to fetch models: ${res.status}`);
const data = await res.json();
return data.data || [];
}
export async function fetchSavings(): Promise<SavingsData> {
const res = await fetch(`${BASE}/v1/savings`);
if (!res.ok) throw new Error(`Failed to fetch savings: ${res.status}`);
return res.json();
}
export async function fetchServerInfo(): Promise<ServerInfo> {
const res = await fetch(`${BASE}/v1/info`);
if (!res.ok) throw new Error(`Failed to fetch server info: ${res.status}`);
return res.json();
}