-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
73 lines (67 loc) · 2.63 KB
/
test.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vote Filter Test</title>
</head>
<body>
<h1>Vote Filter Test</h1>
<form id="voteForm">
<label for="date">Date:</label>
<input
type="text"
id="date"
name="date"
placeholder="Enter date (e.g., 2024-10-31)"
required
/>
<br /><br />
<label for="location">Location:</label>
<input
type="text"
id="location"
name="location"
placeholder="Enter location"
required
/>
<br /><br />
<button type="submit">Submit</button>
</form>
<h2>Response:</h2>
<pre id="response"></pre>
<script>
document
.getElementById('voteForm')
.addEventListener('submit', async function (event) {
event.preventDefault();
const date = document.getElementById('date').value;
const location = document.getElementById('location').value;
try {
const response = await fetch(
`http://localhost:3001/vote/${date}?location=${location}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..nptdCxy19SoAz-yT.8z6AltSTvrA8RfxZCneRnRC3arHk1G_1TipQ8hbipejLivotpfnbwLuwRrsX1iOtsGwhGfBda_2IEwM77sAPQU6wy90vI3HcX5PlfZ9R3hi3bjVkW3PGhG9g9hTrOBSLGsB4c461G5Y4Mqf-PtyLb1lVoPcUOeWmHKXnEen2TlhljTIx5xq7jJQRS50IQ5NdqPvt5y2lmHO8LPBnz1C2SBS-2GRPeDDpJt3MZkDKadTOMpAcnrDnxdPmhmOK1DTD0a_Oha09E0X4L4uahcx0JgkVQkh7TYkZVaTdkgmYuripgpZ2yQdYEMCjM3npr_a1cv22Dq2ahwm9NizxiZnN-JrRFzMXEr5vt9wsi-OcuAGRR8BTPxbf9wDNZSZo-IfAFtsq8Fek2m8BFtTP-22v2rn1K7DY0LmffO4eyZr1hfO9zUqtNtNk-wEs8L15MaDPILsOpstIJ0X-vPdqy2MyflmsN26kOvfLFghBbQ2x9Mj05n0VgfdFgBFJ7riFixDgdxxoNgyGcLWzPZyFplr81HJyErhpytLjMAeW6TPUOBBmccFyxtItnYw0Za4-JLIkU1Jq48xxsIkvq_oMmOgJbTrvqtN6chLyC20Vrd88V-Cz9Iac1GPktj5LZ4M_YdspIXff_FHYEZqXCYIBnyo62JOESxRmpOMrvMU.2WeDaJjtyx61Q050ffvEDw`,
},
},
);
if (!response.ok) {
throw new Error(`Error: ${response.statusText}`);
}
const data = await response.json();
document.getElementById('response').textContent = JSON.stringify(
data,
null,
2,
);
} catch (error) {
document.getElementById('response').textContent =
`Request failed: ${error.message}`;
}
});
</script>
</body>
</html>