From 8688df6f107919579cc937c21dea18e163097b8c Mon Sep 17 00:00:00 2001 From: Override-6 Date: Sun, 4 Dec 2022 05:07:59 +0100 Subject: [PATCH] First interface test with a counter increment --- www/counter/index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/www/counter/index.js b/www/counter/index.js index 6200005..b39a9cd 100644 --- a/www/counter/index.js +++ b/www/counter/index.js @@ -1,11 +1,12 @@ let counter = 0; +const ADDRESS = "92.132.18.192:950" function updateText() { document.getElementById("counter").innerHTML = counter } async function makeIncrement() { - fetch("http://localhost:48485/counter", {method: 'POST'}) + fetch(`http://${ADDRESS}/counter`, {method: 'POST'}) .then(response => { //TODO verify if it's not an error counter++ updateText() @@ -13,14 +14,8 @@ async function makeIncrement() { } 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() - }) + fetch(`http://${ADDRESS}/counter`, {method: 'GET'}) + .then(response => response.json()) .then(json => { counter = json.value updateText()