poll: use async function; provide tsconfig.json
This commit is contained in:
		
							parent
							
								
									d9e0b54b80
								
							
						
					
					
						commit
						6644a8f88c
					
				
					 2 changed files with 33 additions and 8 deletions
				
			
		| 
						 | 
					@ -20,15 +20,30 @@ function save() {
 | 
				
			||||||
	this.newdata = ''
 | 
						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() {
 | 
					function poll() {
 | 
				
			||||||
		fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
 | 
						dopoll(this)
 | 
				
			||||||
			.then((res) => res.json())
 | 
					}
 | 
				
			||||||
			.then((data) => {
 | 
					
 | 
				
			||||||
				console.log(data)
 | 
					function x_poll() {
 | 
				
			||||||
				this.newdata = data['status']
 | 
						fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
 | 
				
			||||||
				this.poll()
 | 
							.then((res) => res.json())
 | 
				
			||||||
			})
 | 
							.then((data) => {
 | 
				
			||||||
		console.log('after fetch')
 | 
								console.log(data)
 | 
				
			||||||
 | 
								this.newdata = data['status']
 | 
				
			||||||
 | 
								this.poll()
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
	return null
 | 
						return null
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										10
									
								
								assets/js/tsconfig.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								assets/js/tsconfig.json
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,10 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						"$schema": "https://json.schemastore.org/tsconfig",
 | 
				
			||||||
 | 
						"display": "ESM",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"compilerOptions": {
 | 
				
			||||||
 | 
							"noEmit": true,
 | 
				
			||||||
 | 
							"module": "es2022",
 | 
				
			||||||
 | 
							"lib": ["es2015", "dom"]
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue