Fixed double fetch

This commit is contained in:
Imbus 2024-02-20 18:41:12 +01:00
parent 3b51c69948
commit 1e96bbe3b6

View file

@ -26,8 +26,7 @@ export function CountButton(): JSX.Element {
// This is what runs on every button click
function press(): void {
async function pressPost(): Promise<void> {
await fetch(BUTTON_ENDPOINT, { method: "POST" });
const response = await fetch(BUTTON_ENDPOINT);
const response = await fetch(BUTTON_ENDPOINT, { method: "POST" });
const data = (await response.json()) as CountResponse;
setCount(data.pressCount);
}