llm-router / apps /web /src /api /analytics.ts
ClaraSu's picture
Upload folder using huggingface_hub
30ac2fc verified
Raw History Blame Contribute Delete
809 Bytes
import { apiFetch } from './client'
import type { Summary, Trends } from '@llm-router/shared'
export async function getSummary(month?: string): Promise<Summary> {
const params = new URLSearchParams()
if (month) params.set('month', month)
const query = params.toString()
const res = await apiFetch(`/v1/expense/summary${query ? `?${query}` : ''}`)
if (!res.ok) throw new Error('Failed to load summary')
return res.json() as Promise<Summary>
}
export async function getTrends(months = 6, month?: string): Promise<Trends> {
const params = new URLSearchParams({ months: String(months) })
if (month) params.set('month', month)
const res = await apiFetch(`/v1/expense/trends?${params.toString()}`)
if (!res.ok) throw new Error('Failed to load trends')
return res.json() as Promise<Trends>
}