Send authorization token

Hi,
I’m trying to send a header which will authorize me to access data.

function authentificationToken(obj){
    console.log(obj);
    let xhr = new XMLHttpRequest();
    xhr.open('GET', 'http://website.com/messages');
    xhr.setRequestHeader("Authorization", "Basic obj");

    let chatText = JSON.parse(xhr.responseText)
}

The token is in obj, however, I don’t think I’m doing the authorization part correctly. My navigator doesn’t see my request, but my console line works.
Thanks you!