fix(helcim): tolerate empty response body on DELETE (204)

helcimFetch called response.json() unconditionally, which threw
"Unexpected end of JSON input" on Helcim's 204 No Content responses
(e.g. DELETE /subscriptions/:id). The error was silently swallowed by
the best-effort cancel path in cancel-subscription, masking cases where
the Helcim-side cancel actually succeeded.
This commit is contained in:
Jennie Robinson Faber 2026-04-18 22:06:33 +01:00
parent 549a849bc0
commit 8ceaebb268

View file

@ -63,7 +63,13 @@ export async function helcimFetch(path, { method = 'GET', body, idempotencyKey,
}) })
} }
return await response.json() const text = await response.text()
if (!text.trim()) return null
try {
return JSON.parse(text)
} catch {
return null
}
} }
// ---- Customers ---- // ---- Customers ----