blob: 6a118a011d10c968801e9bcd781b5da828004d17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
---
layout: page
title: ""
nofollow: true
---
<style>
#result.success { color: green; }
#result.fail { color: red; }
</style>
<span id="result"></span>
<script>
(async () => {
const resultSpan = document.getElementById("result");
function setErr(errStr) {
resultSpan.className = "fail";
resultSpan.innerHTML = errStr;
}
const urlParams = new URLSearchParams(window.location.search);
const unsubToken = urlParams.get('unsubToken');
if (!unsubToken) {
setErr("No unsubscribe token provided");
return;
}
const unsubscribeForm = new FormData();
unsubscribeForm.append('unsubToken', unsubToken);
const unsubscribeReq = new Request('/api/mailinglist/unsubscribe', {
method: 'POST',
body: unsubscribeForm,
});
const res = await fetch(unsubscribeReq)
.then(response => response.json());
if (res.error) {
setErr(res.error);
return;
}
resultSpan.className = "success";
resultSpan.innerHTML = "You have been unsubscribed! Please go on about your day.";
})();
</script>
|