Fetching videos from API within JS app returns empty array

Hi - hoping someone can help me here. I’m fetching videos from the new API. It works, but it always returns an empty data array.

If I do the same with a curl request there is data returned, but it makes no sense why. They’re both doing exactly the same yet the curl request comes back with data and my JS app doesn’t. Am I missing something?

Basic JavaScript example below.

        var xhr = new XMLHttpRequest();

        xhr.addEventListener("readystatechange", function ()
        {
            if (this.readyState === 4)
            {
                console.log(this.responseText);
            }
        });

        xhr.open("GET", "https://api.twitch.tv/helix/videos?game_id=16580");
        xhr.setRequestHeader("Client-ID", "my-client-id");
        xhr.send(data);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.