I have reviewed numerous posts regarding this issue and I am unable to understand why I am still receiving 'undefined' for responseText. The expected json format should be {"token": "ghargaeorigjaoregrjarjegijra[pgjpraejgprjgpkfp5p34i5483te8q9rut053"}
function getAuth(username, password) {
let http = new XMLHttpRequest();
let url, method;
let data = {"username": username, "password": password};
url = returnLocation("default");
method = 'POST';
http.open(method, "http://" + url + "/monitor/admin/auth/", true);
http.setRequestHeader("Content-Type", "application/json");
http.setRequestHeader("Accept", "application/json");
http.send(JSON.stringify(data));
http.onreadystatechange = function() {
if (http.readyState === XMLHttpRequest.DONE && http.status === 200){
setCookie(http.responseText);
}
else if (http.readyState === XMLHttpRequest.DONE && http.status !== 200){
alert(http.statusText);
}
}
}