From a640f3822fbc343c2938c2ee5680756559ac8bd5 Mon Sep 17 00:00:00 2001 From: xingyuv Date: Mon, 27 Mar 2023 16:25:59 +0800 Subject: [PATCH] feat: refreshToken --- src/utils/http/axios/Axios.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts index 23693c8c..b506bd70 100644 --- a/src/utils/http/axios/Axios.ts +++ b/src/utils/http/axios/Axios.ts @@ -113,21 +113,18 @@ export class VAxios { // 1. 获取到刷新token if (getRefreshToken()) { // 2. 进行刷新访问令牌 - console.info('进行刷新访问令牌') try { const refreshTokenRes = await this.refreshToken() // 2.1 刷新成功,则回放队列的请求 + 当前请求 - setAccessToken(refreshTokenRes.data.data) + setAccessToken(refreshTokenRes.data.data.accessToken) ;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() requestList.forEach((cb: any) => { cb() }) requestList = [] - // TODO - console.info('刷新令牌end', res) - // return new Promise((resolve) => { - // resolve(this.axiosInstance(config)) - // }) + return new Promise((resolve) => { + resolve(this.axiosInstance(config)) + }) // res = await Promise.all([this.axiosInstance(config)])[0] } catch (e) { console.info(e)