27 lines
671 B
JavaScript
27 lines
671 B
JavaScript
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');
|
|
}
|
|
} |