completionId: cgen-7c53e2d3b852481b8aa6ac25bce4b268

cgen-7c53e2d3b852481b8aa6ac25bce4b268
This commit is contained in:
Builder.io 2025-11-08 21:49:33 +00:00
parent 1642b066c1
commit 0fbac0515c

View file

@ -172,12 +172,13 @@ export function AdminDiscordManagement() {
},
});
// Read body only once
const data = await response.json().catch(() => ({}));
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.error || "Failed to register commands");
throw new Error(data?.error || "Failed to register commands");
}
const data = await response.json();
setRegisterSuccess(
data.message || "Discord commands registered successfully!",
);