Skip to content

Commit

Permalink
xhr.js: Use AddEventListener instead of directly overwrite the call…
Browse files Browse the repository at this point in the history
…back
  • Loading branch information
NI committed Aug 16, 2020
1 parent a848062 commit b1b5317
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ui/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ export function get(url, headers) {
return new Promise((res, rej) => {
let authReq = new XMLHttpRequest();

authReq.onreadystatechange = () => {
authReq.addEventListener("readystatechange", () => {
if (authReq.readyState !== authReq.DONE) {
return;
}

res(authReq);
};
});

authReq.onerror = e => {
authReq.addEventListener("error", (e) => {
rej(e);
};
});

authReq.ontimeout = e => {
authReq.addEventListener("timeout", (e) => {
rej(e);
};
});

authReq.open("GET", url, true);

Expand Down

0 comments on commit b1b5317

Please sign in to comment.