From c5ae490008828b49374c63bb27e7d73a03d98ab9 Mon Sep 17 00:00:00 2001 From: Fishbakh-N Date: Mon, 6 Apr 2026 08:59:18 +0300 Subject: [PATCH] fix: handle empty response in getCustomization function --- .../src/components/widget/api/index.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/donate-button-v4/src/components/widget/api/index.ts b/packages/donate-button-v4/src/components/widget/api/index.ts index 43a21b2f..1d6a5b66 100644 --- a/packages/donate-button-v4/src/components/widget/api/index.ts +++ b/packages/donate-button-v4/src/components/widget/api/index.ts @@ -56,8 +56,18 @@ export async function getCustomization(nonprofitId: string, code?: string) { const url = `${BASE_API_URL}/${nonprofitId}/customization${ code ? `?code=${code}` : '' }`; - const response: DonateFlowCustomization = await fetch(url).then( - async (response) => response.json() - ); + const response = await fetch(url).then(async (response) => { + const body = await response.text(); + + if (!body) { + return undefined; + } + + try { + return JSON.parse(body) as DonateFlowCustomization; + } catch { + return undefined; + } + }); return response; }