I don’t have much web programming experience but I am trying to retrieve the top 8 streamers for Hearthstone and I am getting the following error.
XMLHttpRequest cannot load https://api.twitch.tv/kraken/streams?game=Hearthstone:+Heroes+of+Warcraft&limit=8. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
Here’s the code that I’m using:
$.getJSON('https://api.twitch.tv/kraken/streams?game=Hearthstone:+Heroes+of+Warcraft&limit=8', function(data) {
var items = [];
$.each(data, function(key, val) {
items.push("<li id='" + key + "'>" + val + "</li>");
});
$("<ul/>", {
"class": "my-new-list",
html: items.join("")
}).appendTo("body");
});
I can view the JSON object on a web browser but it seems that I can’t do it on localhost. Need help!