From 554f952b6fcb2d09857eda57c4e2cbda5590be1b Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Fri, 6 Feb 2026 09:03:05 -0500 Subject: [PATCH] fix(api): handle 204 No Content response in delete method The backend delete endpoint returns 204 No Content with an empty body, but the frontend was attempting to parse the empty response as JSON. This caused a "JSON.parse: unexpected end of data" error when deleting files. The fix adds special handling to not parse JSON for delete responses on success. --- frontend/src/services/api.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/services/api.ts b/frontend/src/services/api.ts index c77a2ec..fcada5e 100644 --- a/frontend/src/services/api.ts +++ b/frontend/src/services/api.ts @@ -43,6 +43,11 @@ export const api = { const response = await fetch(`${API_BASE}/${name}`, { method: 'DELETE', }); - await handleResponse>(response); + if (!response.ok) { + const error: ApiError = await response.json().catch(() => ({ error: 'Unknown error' })); + throw new Error(error.error || `HTTP ${response.status}`); + } + // Don't attempt to parse JSON for 204 No Content + return; }, };