This commit is contained in:
metacryst
2026-04-18 22:17:53 -05:00
parent 12bb270188
commit 6251855ba2
4 changed files with 191 additions and 4 deletions

27
desktoputil.js Normal file
View File

@@ -0,0 +1,27 @@
window.desktopUtil = class desktopUtil {
static async authFetch(url, options = {}) {
const token = localStorage.getItem('auth_token');
return fetch(url, {
...options,
headers: {
...options.headers,
'Authorization': `Bearer ${token}`,
'X-Client': 'desktop'
}
});
}
static async removeAuthToken() {
localStorage.removeItem('auth_token');
}
static async setAuthToken(token) {
localStorage.setItem('auth_token', token);
}
static async getAuthToken() {
return localStorage.getItem('auth_token');
}
}