1
0
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:
2018-04-10 21:51:45 -05:00
parent 27a42f1b99
commit 5fa0f1ac2e
22 changed files with 281 additions and 34 deletions

View 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);
},
);

View File

@@ -0,0 +1,2 @@
export * from './axios.service';
export * from './storage.service';

View 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,
};