mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 05:05:38 -04:00
Replace manual fetch/useState/useEffect patterns with SWR hooks in system health section and command palette search, gaining automatic caching, request deduplication, and stale-while-revalidate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
9 lines
258 B
TypeScript
9 lines
258 B
TypeScript
export async function fetcher<T>(url: string): Promise<T> {
|
|
const res = await fetch(url);
|
|
if (!res.ok) {
|
|
const body = await res.json().catch(() => ({}));
|
|
throw new Error(body.error || `Request failed (${res.status})`);
|
|
}
|
|
return res.json();
|
|
}
|