stuff
This commit is contained in:
27
desktoputil.js
Normal file
27
desktoputil.js
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user