I have the following method that should return either true or false:
theMethod() {
const httpRequest = new XMLHttpRequest();
httpRequest.open("GET", 'http://someurl.com', true);
httpRequest.send();
httpRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
return true;
} else {
return false;
}
};
}
In both cases it's returning 'undefined'
How can I fix this?