File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ export class RefreshScheme<
54
54
{
55
55
public refreshToken : RefreshToken
56
56
public refreshController : RefreshController
57
+ public refreshRequest : Promise < HTTPResponse > | null = null
57
58
58
59
constructor (
59
60
$auth : Auth ,
@@ -174,9 +175,15 @@ export class RefreshScheme<
174
175
175
176
cleanObj ( endpoint . data )
176
177
177
- // Make refresh request
178
- return this . $auth
179
- . request ( endpoint , this . options . endpoints . refresh )
178
+ // When calling refreshTokens() multiple times (parallel axios request)
179
+ // Use the same promise as the first refresh request
180
+ // or making a refresh request if does not exist
181
+ // instead of making parallel refresh request
182
+ this . refreshRequest =
183
+ this . refreshRequest ||
184
+ this . $auth . request ( endpoint , this . options . endpoints . refresh )
185
+
186
+ return this . refreshRequest
180
187
. then ( ( response ) => {
181
188
// Update tokens
182
189
this . updateTokens ( response , { isRefreshing : true } )
@@ -186,6 +193,10 @@ export class RefreshScheme<
186
193
this . $auth . callOnError ( error , { method : 'refreshToken' } )
187
194
return Promise . reject ( error )
188
195
} )
196
+ . finally ( ( ) => {
197
+ // Reset the refresh request
198
+ this . refreshRequest = null
199
+ } )
189
200
}
190
201
191
202
setUserToken (
You can’t perform that action at this time.
0 commit comments