Add Tailwind + shadcn UI primitives; add React Query + Orval client
This commit is contained in:
22
frontend/src/api/mutator.ts
Normal file
22
frontend/src/api/mutator.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export async function customFetch<T>(
|
||||
url: string,
|
||||
options: RequestInit,
|
||||
): Promise<T> {
|
||||
const base = process.env.NEXT_PUBLIC_API_URL;
|
||||
if (!base) throw new Error("NEXT_PUBLIC_API_URL is not set");
|
||||
|
||||
const res = await fetch(`${base}${url}`, {
|
||||
...options,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(options.headers ?? {}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => "");
|
||||
throw new Error(`${res.status} ${res.statusText}${text ? `: ${text}` : ""}`);
|
||||
}
|
||||
|
||||
return (await res.json()) as T;
|
||||
}
|
||||
Reference in New Issue
Block a user