<html lang="gb">
<head>
    <title>Development</title>
    <script src="https://unpkg.com/wrpc-js@latest/cdn.js"></script>
    <script>
        {# The examples below are setting and getting session cookies over fetch #}
        function set_session() {
            fetch(
                'http://127.0.0.1:5000/rpc/auth/login',
                {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: wrpc('login', null),
                }
            )
                .then(response => response.json())
                .then(data => console.log(data));
        }

        function do_fetch() {
            fetch(
                'http://127.0.0.1:5000/rpc/auth',
                {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: wrpc('session', null),
                }
            )
                .then(response => response.json())
                .then(data => console.log(data));
        }
    </script>
</head>

<body>

<button onclick="do_fetch()">Fetch</button>
<button onclick="set_session()">Set Session</button>

</body>
</html>