Split app.js in to smaller chunks
This commit is contained in:
25
public/js/auth.js
Normal file
25
public/js/auth.js
Normal file
@@ -0,0 +1,25 @@
|
||||
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'
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user