Comlete token settle before requesting

pull/9/head
johnniang 2019-04-29 20:43:19 +08:00
parent 26cd673f73
commit 952213649c
2 changed files with 6 additions and 1 deletions

View File

@ -10,7 +10,6 @@ const user = {
roles: [],
info: {}
},
mutations: {
SET_TOKEN: (state, token) => {
Vue.ls.set(ACCESS_TOKEN, token)

View File

@ -3,6 +3,7 @@ import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import Vue from 'vue'
import { message } from 'ant-design-vue'
import store from '@/store'
const service = axios.create({
baseURL: process.env.NODE_ENV === 'production' ? '' : 'http://localhost:8090',
@ -14,6 +15,11 @@ service.interceptors.request.use(
config => {
NProgress.start()
// TODO set token
const token = store.getters.token
Vue.$log.debug('Got token from store', token)
if (token && token.access_token) {
config.headers['Admin-Authorization'] = token.access_token
}
return config
},
error => {