First interface test with a counter increment

production
Override-6 2 years ago
parent cdbdc9278f
commit 8688df6f10

@ -1,11 +1,12 @@
let counter = 0; let counter = 0;
const ADDRESS = "92.132.18.192:950"
function updateText() { function updateText() {
document.getElementById("counter").innerHTML = counter document.getElementById("counter").innerHTML = counter
} }
async function makeIncrement() { 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 .then(response => { //TODO verify if it's not an error
counter++ counter++
updateText() updateText()
@ -13,14 +14,8 @@ async function makeIncrement() {
} }
function initCounter() { function initCounter() {
fetch("http://localhost:48485/counter", {method: 'GET'}) fetch(`http://${ADDRESS}/counter`, {method: 'GET'})
.then(response => { .then(response => response.json())
if (response.ok) {
console.log("response is ok")
}
console.log(response)
return response.json()
})
.then(json => { .then(json => {
counter = json.value counter = json.value
updateText() updateText()