From 4cdf15dfaa284aa14e45ec7212d9fae2568dd395 Mon Sep 17 00:00:00 2001 From: Guido X Jansen Date: Fri, 6 Mar 2026 09:02:16 +0100 Subject: [PATCH] fix(api): handle 204 No Content responses in apiFetch (#193) DELETE endpoints (like unlike/reaction delete) return 204 with empty body. apiFetch was unconditionally calling response.json(), causing "JSON.parse: unexpected end of data" errors. --- src/lib/api/client.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/api/client.ts b/src/lib/api/client.ts index 4bf08de..3e225ac 100644 --- a/src/lib/api/client.ts +++ b/src/lib/api/client.ts @@ -139,6 +139,10 @@ async function apiFetch(path: string, options: FetchOptions = {}): Promise await throwApiError(response) } + if (response.status === 204) { + return undefined as T + } + return response.json() as Promise } -- 2.51.2