25 lines
603 B
JavaScript
25 lines
603 B
JavaScript
export function checkSession() {
|
|
return fetch('/check-session')
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
return response.json();
|
|
});
|
|
}
|
|
|
|
export function login(username, password) {
|
|
return fetch('/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Basic ' + btoa(username + ':' + password)
|
|
}
|
|
});
|
|
}
|
|
|
|
export function logout() {
|
|
return fetch('/logout', {
|
|
method: 'POST'
|
|
});
|
|
} |