API Authentication in JS

I tried using the XMLHttpRequst but I’m not sure how to use it.

function reqListener(){
              console.log(this.responseText);
            }
            var XML = new XMLHttpRequest();
            XML.addEventListener("load", reqListener);
            
            XML.open("GET", "https://api.twitch.tv/helix/streams/<channel>");
            XML.setRequestHeader('Client-ID', '<ID>');

The reqListener function I copied from the mozilla doc. I put the setRequestHeader after the open because XML complained headers can only be set for requests that are ‘opened’.

Using this I get a 404.