From 4e9d954549916ea260583a6b5e36f0c6c02d4d22 Mon Sep 17 00:00:00 2001 From: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Date: Wed, 29 Nov 2023 15:42:46 +0000 Subject: [PATCH] fix(medusa-react): Allow setting maxRetries on MedusaProvider (#5765) * allow settign maxRetries on MedusaProvider * add changeset * set default maxRetries to 3 --- .changeset/large-swans-rule.md | 5 +++++ packages/medusa-react/src/contexts/medusa.tsx | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 .changeset/large-swans-rule.md diff --git a/.changeset/large-swans-rule.md b/.changeset/large-swans-rule.md new file mode 100644 index 0000000000000..f2a5f3cf14b84 --- /dev/null +++ b/.changeset/large-swans-rule.md @@ -0,0 +1,5 @@ +--- +"medusa-react": patch +--- + +fix(medusa-react): Allow setting maxRetries on MedusaProvider diff --git a/packages/medusa-react/src/contexts/medusa.tsx b/packages/medusa-react/src/contexts/medusa.tsx index 0cec47ed6f90b..eb5cafd04aeef 100644 --- a/packages/medusa-react/src/contexts/medusa.tsx +++ b/packages/medusa-react/src/contexts/medusa.tsx @@ -32,6 +32,11 @@ interface MedusaProviderProps { * available within the request */ publishableApiKey?: string + /** + * Number of times to retry a request if it fails + * @default 3 + */ + maxRetries?: number customHeaders?: Record } @@ -41,14 +46,15 @@ export const MedusaProvider = ({ apiKey, publishableApiKey, customHeaders, + maxRetries = 3, children, }: MedusaProviderProps) => { const medusaClient = new Medusa({ baseUrl, - maxRetries: 0, + maxRetries, apiKey, publishableApiKey, - customHeaders + customHeaders, }) return (