2024-09-15 18:11:38 -06:00
|
|
|
function handleErrors(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw Error(response.statusText);
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
function sendMeow(endpoint) {
|
|
|
|
const request = new XMLHttpRequest();
|
|
|
|
request.open("POST", endpoint);
|
|
|
|
request.send("superSecret=null");
|
|
|
|
console.warn(request.response.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getMeowTimeout(endpoint) {
|
|
|
|
const response = await fetch(endpoint)
|
2024-09-16 00:32:12 -06:00
|
|
|
if (response.status === 423) {
|
2024-09-15 18:11:38 -06:00
|
|
|
meowButton.disabled=true;
|
|
|
|
meowButton.innerHTML = "<span>sleeping...</span>";
|
|
|
|
console.warn("TIMED OUT")
|
|
|
|
}
|
2024-09-16 00:32:12 -06:00
|
|
|
if (response.status === 100) {
|
2024-09-15 18:11:38 -06:00
|
|
|
meowButton.disabled=false;
|
|
|
|
meowButton.innerHTML = "<span>meow</span>";
|
|
|
|
console.warn("NOT TIMED OUT")
|
|
|
|
}
|
|
|
|
}
|