File size: 525 Bytes
540eb9d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<script>
async function authFetch(url, options = {}) {
const token = localStorage.getItem("jwt_token");
options.headers = {
...(options.headers || {}),
"Authorization": "Bearer " + token,
"Content-Type": "application/json"
};
const response = await fetch(url, options);
if (response.status === 401) {
alert("Session expired. Please login again.");
window.location.href = "/auth/login";
return;
}
return response.json();
}
</script>
|