fix: handle 204 No Content in DELETE responses
continuous-integration/drone/push Build is passing Details

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.
master
Guillermo Pages 3 weeks ago
parent d29bf7884d
commit 826c42442e

@ -33,6 +33,11 @@ import apiFetch from '@/src/utils/apiFetch';
*/
async function handleApiResponse<T>(response: Response): Promise<FacilityAdminApiResult<T>> {
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

Loading…
Cancel
Save