minor internal changes to make POST form requests to server's page handlers
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
55ec18b75c
commit
44a2078a9f
@ -0,0 +1 @@
|
||||
/home/maxime/Projects/WebstormProjects/tactique-basket-app/platforms/browser
|
@ -1,27 +0,0 @@
|
||||
import {ADDRESS} from "./constants.js";
|
||||
|
||||
let counter = 0;
|
||||
|
||||
window.onload = () => initCounter();
|
||||
window.makeIncrement = () => makeIncrement();
|
||||
|
||||
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()
|
||||
})
|
||||
}
|
Reference in new issue