diff options
-rw-r--r-- | src/views/index.pug | 16 |
1 files changed, 14 insertions, 2 deletions
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 | |||
31 | } | 31 | } |
32 | 32 | ||
33 | async function unsubscribe(sub) { | 33 | async function unsubscribe(sub) { |
34 | await postSubscription(sub, false); | 34 | await postUnsubscription(sub); |
35 | updateButton(sub); | 35 | updateButton(sub); |
36 | } | 36 | } |
37 | 37 | ||
38 | async function postSubscription(sub, subscribe) { | 38 | async function postUnsubscription(sub) { |
39 | const response = await fetch('/unsubscribe', { | ||
40 | method: 'POST', | ||
41 | headers: { | ||
42 | 'Content-Type': 'application/json', | ||
43 | }, | ||
44 | body: JSON.stringify({ subreddit: sub }), | ||
45 | }); | ||
46 | |||
47 | if (!response.ok) { | ||
48 | console.error('Failed to update unsubscription'); | ||
49 | } | ||
50 | } | ||
39 | const response = await fetch('/subscribe', { | 51 | const response = await fetch('/subscribe', { |
40 | method: 'POST', | 52 | method: 'POST', |
41 | headers: { | 53 | headers: { |