You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default API requests are retried up to 15 times on 429 and 5xx errors and credential requests are retried to 3 times on 429 and 5xx errors. In both instances they will wait a minimum of 100 milliseconds between requests and up to a maximum of
669
+
If a network request fails with a 429 or 5xx error from the server, the SDK will automatically retry the request up to 15 times with a minimum wait time of 100 milliseconds between each attempt.
670
+
671
+
To customize this behavior, create an object with `maxRetry` and `minWaitInMs` properties. `maxRetry` determines the maximum number of retries (up to 15), while `minWaitInMs` sets the minimum wait time between retries in milliseconds.
626
672
627
-
In order to change the behavior for API requests, pass a `retryParams`object in the `OpenFgaClient` constructor with a `maxRetry` property to control the amount of retries and a `minWaitInMs` to control the minimum wait time between retried requests.
673
+
Apply your custom retry values by setting to `retryParams`on the to the configuration object passed to the `OpenFgaClient` call.
628
674
629
675
```javascript
630
676
const { OpenFgaClient } =require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';
631
677
632
678
constfgaClient=newOpenFgaClient({
633
679
apiUrl:process.env.FGA_API_URL, // required
634
680
storeId:process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
635
-
authorizationModelId:process.env.FGA_AUTHORIZATION_MODEL_ID, // Optional, can be overridden per request
681
+
authorizationModelId:process.env.FGA_MODEL_ID, // Optional, can be overridden per request
636
682
retryParams: {
637
683
maxRetry:3, // retry up to 3 times on API requests
638
684
minWaitInMs:250// wait a minimum of 250 milliseconds between requests
0 commit comments