You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
703 B
29 lines
703 B
let counter = 0;
|
|
|
|
function updateText() {
|
|
document.getElementById("counter").innerHTML = counter
|
|
}
|
|
|
|
async function makeIncrement() {
|
|
fetch("http://localhost:48485/counter", {method: 'POST'})
|
|
.then(response => { //TODO verify if it's not an error
|
|
counter++
|
|
updateText()
|
|
})
|
|
}
|
|
|
|
function initCounter() {
|
|
fetch("http://localhost:48485/counter", {method: 'GET'})
|
|
.then(response => {
|
|
if (response.ok) {
|
|
console.log("response is ok")
|
|
}
|
|
console.log(response)
|
|
return response.json()
|
|
})
|
|
.then(json => {
|
|
counter = json.value
|
|
updateText()
|
|
})
|
|
}
|