diff --git a/assets/js/main.ts b/assets/js/main.ts index 6c422db..96751fc 100644 --- a/assets/js/main.ts +++ b/assets/js/main.ts @@ -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 } diff --git a/assets/js/tsconfig.json b/assets/js/tsconfig.json new file mode 100644 index 0000000..50c5c5a --- /dev/null +++ b/assets/js/tsconfig.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "display": "ESM", + + "compilerOptions": { + "noEmit": true, + "module": "es2022", + "lib": ["es2015", "dom"] + } +}