temperature-alarm/frontend/shared/utils.js
2025-03-25 16:11:14 +01:00

19 lines
496 B
JavaScript

export async function handleResponse(response) {
const json = await response.json();
if (response.ok || json.error) return json;
if (json.errors) {
return { error: Object.values(response.errors)[0][0] };
}
return { error: "Request failed with HTTP code " + response.status };
}
document.querySelectorAll(".logoutContainer").forEach(closeBtn => {
closeBtn.onclick = () => {
localStorage.clear();
window.location.href = "/index.html";
};
});