mirror of
https://github.com/mgerb/go-discord-bot
synced 2026-01-11 01:22:48 +00:00
statistics tab for discord chat
This commit is contained in:
19
client/app/services/axios.service.ts
Normal file
19
client/app/services/axios.service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import ax from 'axios';
|
||||
import { StorageService } from './storage.service';
|
||||
|
||||
export const axios = ax.create();
|
||||
|
||||
axios.interceptors.request.use(
|
||||
config => {
|
||||
const jwt = StorageService.getJWT();
|
||||
if (jwt) {
|
||||
config.headers['Authorization'] = `Bearer ${jwt}`;
|
||||
}
|
||||
// Do something before request is sent
|
||||
return config;
|
||||
},
|
||||
function(error) {
|
||||
// Do something with request error
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
2
client/app/services/index.ts
Normal file
2
client/app/services/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './axios.service';
|
||||
export * from './storage.service';
|
||||
17
client/app/services/storage.service.ts
Normal file
17
client/app/services/storage.service.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
const clear = () => {
|
||||
localStorage.clear();
|
||||
};
|
||||
|
||||
const setJWT = (token: string) => {
|
||||
localStorage.setItem('jwt', token);
|
||||
};
|
||||
|
||||
const getJWT = (): string | null => {
|
||||
return localStorage.getItem('jwt');
|
||||
};
|
||||
|
||||
export const StorageService = {
|
||||
clear,
|
||||
getJWT,
|
||||
setJWT,
|
||||
};
|
||||
Reference in New Issue
Block a user