I have this method, which has an IF statement and returns this.status.
Here is the code:
myMethod() {
return new Promise(resolve => {
let httpRequest = new XMLHttpRequest();
httpRequest.open("GET", "http://someurl.com", true);
httpRequest.send();
httpRequest.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// I need this.status to be able to use outside here
}
};
resolve();
})
}
How can I get this.status result outside the if() {} area so I can pass it to other methods?