Advertisement
Guest User

Twitch JavaScript

a guest
Mar 5th, 2021
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var executed = false;
  2.  
  3. setInterval(() => {
  4.   $.ajax({
  5.     type: 'GET',
  6.     url: 'https://api.twitch.tv/helix/streams?user_login=username',
  7.     dataType: 'json',
  8.     headers: {
  9.       'Client-Id': 'clientid',
  10.       'Authorization': 'token'
  11.     },
  12.     success: function(channel) {
  13.       if (channel["data"] == "") {
  14.         executed = false;
  15.       } else {
  16.         if (!executed) {
  17.           //do stuff
  18.           executed = true;
  19.         }
  20.       }
  21.     }
  22.   });
  23. }, 2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement