poll: use async function; provide tsconfig.json

This commit is contained in:
Helmut Merz 2023-02-20 10:51:55 +01:00
parent d9e0b54b80
commit 6644a8f88c
2 changed files with 33 additions and 8 deletions

View file

@ -20,15 +20,30 @@ function save() {
this.newdata = ''
}
const apiUrl = 'http://localhost:8125/api/system/poll/service/pclt-0001'
async function dopoll(obj: typeof appdata) {
while (true) {
let res = await fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
//let res = await fetch(apiUrl)
let data = await res.json()
console.log(data)
obj.newdata = data['status']
}
}
function poll() {
fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
.then((res) => res.json())
.then((data) => {
console.log(data)
this.newdata = data['status']
this.poll()
})
console.log('after fetch')
dopoll(this)
}
function x_poll() {
fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
.then((res) => res.json())
.then((data) => {
console.log(data)
this.newdata = data['status']
this.poll()
})
return null
}

10
assets/js/tsconfig.json Normal file
View file

@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "ESM",
"compilerOptions": {
"noEmit": true,
"module": "es2022",
"lib": ["es2015", "dom"]
}
}