Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

SDK fetch fix

Damian Legawiec614bb465aedc
diff --git a/sdk/src/client.ts b/sdk/src/client.ts
index d0061d8dc3..d4dd39bd3d 100644
--- a/sdk/src/client.ts
+++ b/sdk/src/client.ts
@@ -68,7 +68,8 @@ export class SpreeClient {
constructor(config: SpreeClientConfig) {
this.baseUrl = config.baseUrl.replace(/\/$/, '');
this.apiKey = config.apiKey;
- this.fetchFn = config.fetch || fetch;
+ // Bind fetch to globalThis to avoid "Illegal invocation" errors in browsers
+ this.fetchFn = config.fetch || fetch.bind(globalThis);
}
private async request<T>(