|
|
@ -32,12 +32,12 @@ axios.interceptors.response.use(function (response) {
|
|
|
|
if (error.response.status === 401 && error.config.url.indexOf('refreshToken') === -1) {
|
|
|
|
if (error.response.status === 401 && error.config.url.indexOf('refreshToken') === -1) {
|
|
|
|
var url = '/UserCenter/api/v1/token/refreshToken';
|
|
|
|
var url = '/UserCenter/api/v1/token/refreshToken';
|
|
|
|
var data = '"' + store.state.refreshToken + '"';
|
|
|
|
var data = '"' + store.state.refreshToken + '"';
|
|
|
|
axios.post(url, data, { headers: { 'Content-Type': 'application/json;charset=UTF-8' } })
|
|
|
|
return axios.post(url, data, { headers: { 'Content-Type': 'application/json;charset=UTF-8' } })
|
|
|
|
.then(function (response) {
|
|
|
|
.then(function (response) {
|
|
|
|
store.commit('setToken', response.data);
|
|
|
|
store.commit('setToken', response.data);
|
|
|
|
error.config.headers['Authorization'] = 'Bearer ' + store.state.accessToken;
|
|
|
|
error.config.headers['Authorization'] = 'Bearer ' + store.state.accessToken;
|
|
|
|
console.log('刷新token后重发api请求');
|
|
|
|
console.log('刷新token后重发api请求');
|
|
|
|
axios.request(error.config);
|
|
|
|
return axios(error.config);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
.catch(function (error) {
|
|
|
|
if (error.response.status === 401) {
|
|
|
|
if (error.response.status === 401) {
|
|
|
|