diff --git a/apps/web/src/lib/api/client.ts b/apps/web/src/lib/api/client.ts index a1e0d14..f9504e1 100644 --- a/apps/web/src/lib/api/client.ts +++ b/apps/web/src/lib/api/client.ts @@ -71,12 +71,9 @@ export async function apiForm(path: string, form: FormData): Promise { const res = await fetch(`${API_BASE}${path}`, { method: 'POST', headers, body: form }); if (!res.ok) { - let body: unknown = null; - try { - body = await res.json(); - } catch { - body = await res.text(); - } + const text = await res.text(); + let body: unknown = text; + try { body = JSON.parse(text); } catch { /* keep text */ } throw new ApiError(res.status, body); } return (await res.json()) as T; @@ -105,12 +102,9 @@ export async function api(path: string, opts: RequestOptions = {}): Promise