Skip to content

Instantly share code, notes, and snippets.

@pasza01
Created July 21, 2015 21:48
Show Gist options
  • Save pasza01/303273da32bf8f0bc853 to your computer and use it in GitHub Desktop.
Save pasza01/303273da32bf8f0bc853 to your computer and use it in GitHub Desktop.
var xmlhttp = new XMLHttpRequest();
var url = "http://api.twitch.tv/api/channels/lirik";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
myFunction(myArr);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(arr) {
var out = 'Name: '+ arr.name +'</br>' +'Game: ' + arr.game
+'</br>' +'Status: ' + arr.status+'</br>' +'Partner: ' + arr.partner ;
document.getElementById("id01").innerHTML =out;
}
<!DOCTYPE html>
<html>
<body>
<h1>Twitch api call</h1>
<div id="id01"></div>
<script src="/api/apitwitch.js" type="text/javascript"></script>
</body>
</html>
@pasza01
Copy link
Author

pasza01 commented Jul 21, 2015

....src may vary on index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment