rest api azure devops

rest api azure devops

Hi, I'm really struggling to get the authenication header to work, to access my azure devops. I've tested the path and the Personal Access Token (PAT) with powershell. Everything works. 
I just cannot get the same to work in javascript/jquery. Please see my code below. I've put down two different ways I've tried and commented it them out. would really appreciate the help.

// var username = "username";
// var password = "54--PAT-TOKEN--xq";

var vstsAuthHeader = { "Authorization": "Basic " + btoa("" + ":" + "54--PAT-TOKEN----xq") }

    url: '',
    type: "GET",
    dataType: 'JSON',
 beforeSend: function (xhr){ 

                //xhr.setRequestHeader('Authorization', "Basic "+ btoa(username + ':' + password)); 
    success: function(data){
        if (data.success) {

     alert("Oh yes!");

            alert("Oops, an error occurred fetching the remote data.");