live message! (limit:1)
This commit is contained in:
parent
2fc501d2bf
commit
8cc191dad1
3 changed files with 39 additions and 15 deletions
|
@ -1,23 +1,23 @@
|
|||
import axios from "axios";
|
||||
|
||||
let shouldRun = false
|
||||
let accesstoken
|
||||
onmessage = (event) => {
|
||||
const { action, access_token } = event.data
|
||||
accesstoken=access_token
|
||||
|
||||
if (action === "start") {
|
||||
shouldRun = true
|
||||
fetchData(access_token)
|
||||
fetchData()
|
||||
} else if (action === "terminate") {
|
||||
shouldRun = false
|
||||
}
|
||||
}
|
||||
|
||||
console.log('starting get loop');
|
||||
|
||||
const fetchData = (access_token) => {
|
||||
if (!shouldRun) return
|
||||
|
||||
const fetchData = () => {
|
||||
console.log(accesstoken);
|
||||
|
||||
const apiURL = "http://localhost:5000/interstellar/api/ai_get?access_token="+access_token
|
||||
|
||||
const apiURL = "http://localhost:5000/interstellar/api/ai_get?access_token="+accesstoken
|
||||
|
||||
axios.get(apiURL)
|
||||
.then(response => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue