Use Fetch API

This commit is contained in:
MeowcaTheoRange 2022-09-14 09:44:56 -05:00 committed by GitHub
parent 2dd1f19d05
commit b05d53025c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,10 +5,8 @@ setInterval(reqData, 60000);
//balls lmao
function reqData() {
const XHR = new XMLHttpRequest();
XHR.addEventListener("load", (event) => {
var resp = event.target.response;
var donedata = (e) => {
var resp = e;
if (event.target.status.toString().includes("40")) {
console.log(event.target.status + " error :[")
@ -26,15 +24,11 @@ function reqData() {
localStorage.setItem("commitsha", resp);
}
}
});
};
XHR.addEventListener("error", (event) => {
console.log('Oops! Something went wrong.');
});
XHR.open("GET", "https://ClockCheckGithub.meowcatheorange.repl.co");
XHR.send();
fetch("https://ClockCheckGithub.meowcatheorange.repl.co")
.then(x => x.text())
.then(y => donedata(y));
}
reqData();