Skip to content

Commit b3355c1

Browse files
authored
Add skipInitialFetch Option (#40)
* Add `skipInitialFetch` Option * Bump version to 2.0.23
1 parent 91d8589 commit b3355c1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "git",
66
"url": "https://github.com/PropelAuth/javascript"
77
},
8-
"version": "2.0.22",
8+
"version": "2.0.23",
99
"keywords": [
1010
"auth",
1111
"user",

src/client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ export interface IAuthOptions {
191191
* Default false
192192
*/
193193
disableRefreshOnFocus?: boolean
194+
195+
/**
196+
* If true, disables the token refresh on initial page load.
197+
* Can help reduce duplicate token refresh requests.
198+
*
199+
* Default false
200+
*/
201+
skipInitialFetch?: boolean
194202
}
195203

196204
interface AccessTokenActiveOrgMap {
@@ -666,7 +674,9 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
666674
}
667675

668676
if (authOptions.enableBackgroundTokenRefresh) {
669-
client.getAuthenticationInfoOrNull()
677+
if (!authOptions.skipInitialFetch) {
678+
client.getAuthenticationInfoOrNull()
679+
}
670680
clientState.refreshInterval = window.setInterval(client.getAuthenticationInfoOrNull, 60000)
671681
}
672682
}

0 commit comments

Comments
 (0)