Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1.  
  2. window.addEventListener('load' , function(){
  3.  
  4. var demo = document.getElementById('demo');
  5.  
  6. function getSource(method, url) {
  7.  
  8. var xmlhttp = new XMLHttpRequest();
  9.  
  10. xmlhttp.open(method, url, true);
  11.  
  12. xmlhttp.onload = function () {
  13. if (this.status === 200) {
  14. var channels = JSON.parse(this.responseText);
  15.  
  16.  
  17.  
  18. var output = "";
  19. // console.log(channels);
  20. for (var i in channels.follows) {
  21. console.log(channels.follows[i].channel);
  22. output += '<div class="channel"><h4>' + channels.follows[i].channel.display_name + '</h4></div>';
  23.  
  24. // console.log(channels.follows[i].channel.display_name);
  25. }
  26.  
  27. demo.innerHTML = output;
  28.  
  29. }
  30. }
  31.  
  32. xmlhttp.send();
  33. }
  34.  
  35. getSource('GET' , 'https://wind-bow.glitch.me/twitch-api/users/chlenososik/follows/channels');
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement