Skip to content

Commit

Permalink
fix: assign default fetch implementation dynamically to work with msw
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Dec 4, 2024
1 parent 311b863 commit fa8b0f1
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-spies-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/client-fetch': patch
---

fix: assign default fetch implementation dynamically to work with msw
1 change: 1 addition & 0 deletions packages/client-fetch/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const createClient = (config: Config = {}): Client => {
const opts: RequestOptions = {
..._config,
...options,
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
headers: mergeHeaders(_config.headers, options.headers),
};
if (opts.body && opts.bodySerializer) {
Expand Down
1 change: 0 additions & 1 deletion packages/client-fetch/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ const defaultHeaders = {
export const createConfig = (override: Config = {}): Config => ({
...jsonBodySerializer,
baseUrl: '',
fetch: globalThis.fetch,
headers: defaultHeaders,
parseAs: 'auto',
querySerializer: defaultQuerySerializer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const createClient = (config: Config = {}): Client => {
const opts: RequestOptions = {
..._config,
...options,
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
headers: mergeHeaders(_config.headers, options.headers),
};
if (opts.body && opts.bodySerializer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ const defaultHeaders = {
export const createConfig = (override: Config = {}): Config => ({
...jsonBodySerializer,
baseUrl: '',
fetch: globalThis.fetch,
headers: defaultHeaders,
parseAs: 'auto',
querySerializer: defaultQuerySerializer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const createClient = (config: Config = {}): Client => {
const opts: RequestOptions = {
..._config,
...options,
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
headers: mergeHeaders(_config.headers, options.headers),
};
if (opts.body && opts.bodySerializer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ const defaultHeaders = {
export const createConfig = (override: Config = {}): Config => ({
...jsonBodySerializer,
baseUrl: '',
fetch: globalThis.fetch,
headers: defaultHeaders,
parseAs: 'auto',
querySerializer: defaultQuerySerializer,
Expand Down

0 comments on commit fa8b0f1

Please sign in to comment.