From 952213649c0f1836b86eeebef7ed5696ed01c4ba Mon Sep 17 00:00:00 2001 From: johnniang Date: Mon, 29 Apr 2019 20:43:19 +0800 Subject: [PATCH] Comlete token settle before requesting --- src/store/modules/user.js | 1 - src/utils/service.js | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 91e573d9..3f4de908 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -10,7 +10,6 @@ const user = { roles: [], info: {} }, - mutations: { SET_TOKEN: (state, token) => { Vue.ls.set(ACCESS_TOKEN, token) diff --git a/src/utils/service.js b/src/utils/service.js index cda00349..a704835e 100644 --- a/src/utils/service.js +++ b/src/utils/service.js @@ -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 => {