From b05d53025cd3055e5cf476881ffda41dc1925ff8 Mon Sep 17 00:00:00 2001 From: MeowcaTheoRange <58280776+MeowcaTheoRange@users.noreply.github.com> Date: Wed, 14 Sep 2022 09:44:56 -0500 Subject: [PATCH] Use Fetch API --- update.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/update.js b/update.js index c90f907..be33758 100644 --- a/update.js +++ b/update.js @@ -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(); \ No newline at end of file