summaryrefslogtreecommitdiff
path: root/static/src/mailinglist/finalize.md
blob: a80809d009b033708c9e809bd5b16436b266f37c (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
---
layout: page
title: ""
nofollow: true
---

<script async type="module" src="/assets/api.js"></script>

<style>
#result.success { color: green; }
#result.fail { color: red; }
</style>

<span id="result"></span>

<script>

(async () => {

    const resultSpan = document.getElementById("result");

    try {

        const urlParams = new URLSearchParams(window.location.search);
        const subToken = urlParams.get('subToken');

        if (!subToken) throw "No subscription token provided";

        const api = await import("/assets/api.js");

        await api.call('/api/mailinglist/finalize', {
            body: { subToken },
        });

        resultSpan.className = "success";
        resultSpan.innerHTML = "Your email subscription has been finalized! Please go on about your day.";

    } catch (e) {
        resultSpan.className = "fail";
        resultSpan.innerHTML = e;
    }

})();

</script>