From 826c42442ef9432efaf76f2296fbd1407e057097 Mon Sep 17 00:00:00 2001 From: Guillermo Pages Date: Mon, 24 Nov 2025 13:15:08 +0100 Subject: [PATCH] fix: handle 204 No Content in DELETE responses DELETE endpoints (deletePlan, deleteEntitlement, deleteMember) return 204 with empty body. handleApiResponse was trying to parse JSON from empty response, causing: 'Unexpected end of JSON input' Fix: Check for status 204 before calling response.json() Return { success: true, data: undefined } for 204 responses This resolves console error while maintaining successful delete operations. --- src/lib/api/facility-admin.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/api/facility-admin.ts b/src/lib/api/facility-admin.ts index e374f5d..cdb6e1a 100644 --- a/src/lib/api/facility-admin.ts +++ b/src/lib/api/facility-admin.ts @@ -33,6 +33,11 @@ import apiFetch from '@/src/utils/apiFetch'; */ async function handleApiResponse(response: Response): Promise> { if (response.ok) { + // Handle 204 No Content - DELETE endpoints return empty body + if (response.status === 204) { + return { success: true, data: undefined as T }; + } + const json = await response.json(); // Flask returns { status: 'success', data: {...} } // Extract the actual data from the wrapper