From 81adffe4c1ecd2f0260ec08e73760505dfe4edaa Mon Sep 17 00:00:00 2001 From: "Akshay\" (aider)" Date: Wed, 13 Nov 2024 21:32:03 +0000 Subject: fix: Update unsubscribe function to call /unsubscribe endpoint --- src/views/index.pug | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/views/index.pug b/src/views/index.pug index dbd246f..513491d 100644 --- a/src/views/index.pug +++ b/src/views/index.pug @@ -31,11 +31,23 @@ html } async function unsubscribe(sub) { - await postSubscription(sub, false); + await postUnsubscription(sub); updateButton(sub); } - async function postSubscription(sub, subscribe) { + async function postUnsubscription(sub) { + const response = await fetch('/unsubscribe', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ subreddit: sub }), + }); + + if (!response.ok) { + console.error('Failed to update unsubscription'); + } + } const response = await fetch('/subscribe', { method: 'POST', headers: { -- cgit v1.2.3