Alright, made requests authenticated with middleman

This commit is contained in:
MeowcaTheoRange 2022-09-13 11:24:16 -05:00
parent 0a427f1e00
commit 8198300fa6

View file

@ -6,17 +6,22 @@ function reqData() {
const XHR = new XMLHttpRequest(); const XHR = new XMLHttpRequest();
XHR.addEventListener("load", (event) => { XHR.addEventListener("load", (event) => {
var resp = JSON.parse(event.target.response); var resp = event.target.response;
if (resp.sha != prevSha) { if (event.target.status.toString().includes("40")) {
console.log(event.target.status + " error :[")
return;
}
if (resp != prevSha) {
if (prevSha == "ThisShouldntBeASHA") { if (prevSha == "ThisShouldntBeASHA") {
localStorage.setItem("commitsha", resp.sha); localStorage.setItem("commitsha", resp);
} else { } else {
document.querySelector(".scr-update--").classList.add("open"); document.querySelector(".scr-update--").classList.add("open");
setTimeout(() => { setTimeout(() => {
window.location.href = window.location.href; window.location.href = window.location.href;
}, 15000); }, 15000);
localStorage.setItem("commitsha", resp.sha); localStorage.setItem("commitsha", resp);
} }
} }
}); });
@ -25,7 +30,7 @@ function reqData() {
console.log('Oops! Something went wrong.'); console.log('Oops! Something went wrong.');
}); });
XHR.open("GET", "https://api.github.com/repos/meowcatheorange/clock/commits/master"); XHR.open("GET", "https://ClockCheckGithub.meowcatheorange.repl.co");
XHR.send(); XHR.send();
} }