let counter = 0; const ADDRESS = "92.132.18.192:950" function updateText() { document.getElementById("counter").innerHTML = counter } async function makeIncrement() { fetch(`http://${ADDRESS}/counter`, {method: 'POST'}) .then(response => { //TODO verify if it's not an error counter++ updateText() }) } function initCounter() { fetch(`http://${ADDRESS}/counter`, {method: 'GET'}) .then(response => response.json()) .then(json => { counter = json.value updateText() }) }