-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
30 lines (27 loc) · 888 Bytes
/
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Counter</title>
</head>
<body>
<h1>Counter: <span id="counterValue">0</span></h1>
<button id="incrementBtn">Increment Counter</button>
<script>
function getCounter() {
fetch('/api/counter')
.then(response => response.json())
.then(data => {
document.getElementById('counterValue').textContent = data;
});
}
function incrementCounter() {
fetch('/api/counter/increment', { method: 'POST' })
.then(() => getCounter());
}
window.onload = getCounter;
document.getElementById('incrementBtn').addEventListener('click', incrementCounter);
</script>
</body>
</html>