diff --git a/www/counter/index.html b/www/counter/index.html new file mode 100644 index 0000000..c532488 --- /dev/null +++ b/www/counter/index.html @@ -0,0 +1,18 @@ + + + + + + Counter + + + +
+ + + +
+ + + + \ No newline at end of file diff --git a/www/counter/index.js b/www/counter/index.js new file mode 100644 index 0000000..6200005 --- /dev/null +++ b/www/counter/index.js @@ -0,0 +1,28 @@ +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() + }) +}