mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-06 08:18:58 +00:00
Throw Response from apiJson so API 404s render as 404 pages
apiJson was throwing a plain Error on non-ok responses, which React Router always treated as a 500. Now throws a Response with the actual status code so API 404s surface as proper 404 error pages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcba787cd5
commit
e938d3395a
1 changed files with 1 additions and 1 deletions
|
|
@ -51,6 +51,6 @@ export async function apiFetch(
|
|||
*/
|
||||
export async function apiJson<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await apiFetch(path, init);
|
||||
if (!res.ok) throw new Error(`API ${res.status}: ${await res.text()}`);
|
||||
if (!res.ok) throw new Response(await res.text(), { status: res.status });
|
||||
return res.json() as Promise<T>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue