Use Fetch API
This commit is contained in:
parent
2dd1f19d05
commit
b05d53025c
1 changed files with 6 additions and 12 deletions
18
update.js
18
update.js
|
@ -5,10 +5,8 @@ setInterval(reqData, 60000);
|
||||||
//balls lmao
|
//balls lmao
|
||||||
|
|
||||||
function reqData() {
|
function reqData() {
|
||||||
const XHR = new XMLHttpRequest();
|
var donedata = (e) => {
|
||||||
|
var resp = e;
|
||||||
XHR.addEventListener("load", (event) => {
|
|
||||||
var resp = event.target.response;
|
|
||||||
|
|
||||||
if (event.target.status.toString().includes("40")) {
|
if (event.target.status.toString().includes("40")) {
|
||||||
console.log(event.target.status + " error :[")
|
console.log(event.target.status + " error :[")
|
||||||
|
@ -26,15 +24,11 @@ function reqData() {
|
||||||
localStorage.setItem("commitsha", resp);
|
localStorage.setItem("commitsha", resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
XHR.addEventListener("error", (event) => {
|
fetch("https://ClockCheckGithub.meowcatheorange.repl.co")
|
||||||
console.log('Oops! Something went wrong.');
|
.then(x => x.text())
|
||||||
});
|
.then(y => donedata(y));
|
||||||
|
|
||||||
XHR.open("GET", "https://ClockCheckGithub.meowcatheorange.repl.co");
|
|
||||||
|
|
||||||
XHR.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reqData();
|
reqData();
|
Loading…
Reference in a new issue