Very new to JS and am trying to make a GET request to an API with a header. The below code appears to work (no errors) but I don't understand how to get it to print the data it has collected from the API.
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", 'URL');
xmlHttp.headers({'Authorization': 'Token REDACTED'});
xmlHttp.send( null );
return xmlHttp.responseText;
}
Basically am trying to do what this python code does:
header = {'Authorization': 'Token REDACTED'}
response = requests.get("URL", headers = header)
print response.content