feat: refreshToken

pull/4/MERGE
xingyuv 2023-03-27 16:25:59 +08:00
parent 0ed8e09f2b
commit a640f3822f
1 changed files with 4 additions and 7 deletions

View File

@ -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)