fix(medusa-react): Allow setting maxRetries on MedusaProvider (#5765)

* allow settign maxRetries on MedusaProvider

* add changeset

* set default maxRetries to 3
This commit is contained in:
Kasper Fabricius Kristensen
2023-11-29 15:42:46 +00:00
committed by GitHub
parent f802e2460f
commit 4e9d954549
2 changed files with 13 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"medusa-react": patch
---
fix(medusa-react): Allow setting maxRetries on MedusaProvider
@@ -32,6 +32,11 @@ interface MedusaProviderProps {
* available within the request * available within the request
*/ */
publishableApiKey?: string publishableApiKey?: string
/**
* Number of times to retry a request if it fails
* @default 3
*/
maxRetries?: number
customHeaders?: Record<string, any> customHeaders?: Record<string, any>
} }
@@ -41,14 +46,15 @@ export const MedusaProvider = ({
apiKey, apiKey,
publishableApiKey, publishableApiKey,
customHeaders, customHeaders,
maxRetries = 3,
children, children,
}: MedusaProviderProps) => { }: MedusaProviderProps) => {
const medusaClient = new Medusa({ const medusaClient = new Medusa({
baseUrl, baseUrl,
maxRetries: 0, maxRetries,
apiKey, apiKey,
publishableApiKey, publishableApiKey,
customHeaders customHeaders,
}) })
return ( return (
<QueryClientProvider {...queryClientProviderProps}> <QueryClientProvider {...queryClientProviderProps}>