Skip to content

Commit 61fbf11

Browse files
authored
fix: prevent fetching customization without a code (#458)
1 parent 91bed72 commit 61fbf11

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/donate-button-v4/src/components/widget/context/NonprofitContext.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,18 @@ export const NonprofitContextProvider: FunctionalComponent<{
6262
}
6363
}
6464

65-
try {
66-
const customizationResponse = await getCustomization(response.id, code);
67-
setCustomization(customizationResponse);
68-
} catch {
69-
setCustomization(DonateFlowCustomizationFetchError);
65+
if (code) {
66+
try {
67+
const customizationResponse = await getCustomization(
68+
response.id,
69+
code
70+
);
71+
setCustomization(customizationResponse);
72+
} catch {
73+
setCustomization(DonateFlowCustomizationFetchError);
74+
}
75+
} else {
76+
setCustomization(undefined);
7077
}
7178
} catch {
7279
setNonprofit(NonprofitFetchError);

0 commit comments

Comments
 (0)