-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (36 loc) · 1.26 KB
/
index.html
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
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<title>Testing session store</title>
</head>
<body style="text-align: center;" onload="login();loadSessionTable();">
<h1>Home</h1>
<p id="connected">not connected :(</p>
<input type="text" id="username" placeholder="username">
<button onclick="login()">login</button>
<h4>session table :</h4><br>
<pre>empty</pre>
<script>
async function login() {
const respone = await fetch('http://localhost:3000/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({ username: document.getElementById('username').value }),
})
const data = await respone.json()
if (data.success) {
document.getElementById('connected').innerText = 'connected :)'
}
}
async function loadSessionTable() {
const respone = await fetch('http://localhost:3000/session_table')
const data = await respone.json()
document.querySelector('pre').innerText = JSON.stringify(data, null, 2)
}
</script>
</body>
</html>