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() }) }