22 lines
606 B
JavaScript
22 lines
606 B
JavaScript
import { Preferences } from '@capacitor/preferences';
|
|
|
|
export default class util {
|
|
static async authFetch(url, options = {}) {
|
|
const { value: token } = await Preferences.get({ key: 'auth_token' });
|
|
|
|
return fetch(url, {
|
|
...options,
|
|
headers: {
|
|
...options.headers,
|
|
'Authorization': `Bearer ${token}`,
|
|
'X-Client': 'mobile'
|
|
}
|
|
});
|
|
}
|
|
|
|
static cssVariable(value) {
|
|
return getComputedStyle(document.documentElement)
|
|
.getPropertyValue("--" + value)
|
|
.trim();
|
|
}
|
|
} |