First interface test with a counter increment

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

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