Hi, so i want to check if a specific user is live or not. I used a while loop to check every second, but everytime the user goes live, the api request executes and finds the user but then right after in the next request, there is no data found wich then my code thinks the user has gone offline again.
async function getStream(){
while(true){
const streams = await twitch.getStreams({ channel: "testname" });
if(streams.data.length > 0){
console.log("online")
}else{
console.log("offline")
}
await sleep(1000)
}
}
getStream();
so the output is this:
offline
offline
offline
- online
- offline (while user is live)
online
online
etc
Why is this? thanks in advance