Skip to content

Commit

Permalink
Fix global responseHandler being used in fetchBaseQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
praxxis committed Jan 30, 2023
1 parent 034b086 commit 184fedd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/toolkit/src/query/fetchBaseQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export function fetchBaseQuery({
jsonContentType = 'application/json',
jsonReplacer,
timeout: defaultTimeout,
responseHandler: globalResponseHandler,
validateStatus: globalValidateStatus,
...baseFetchOptions
}: FetchBaseQueryArgs = {}): BaseQueryFn<
Expand All @@ -218,7 +219,7 @@ export function fetchBaseQuery({
url,
headers = new Headers(baseFetchOptions.headers),
params = undefined,
responseHandler = 'json' as const,
responseHandler = globalResponseHandler ?? ('json' as const),
validateStatus = globalValidateStatus ?? defaultValidateStatus,
timeout = defaultTimeout,
...rest
Expand Down
3 changes: 2 additions & 1 deletion packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ describe('fetchBaseQuery', () => {
})

const req = globalizedBaseQuery(
{ url: '/success', responseHandler: 'text' },
{ url: '/success' },
commonBaseQueryApi,
{}
)
Expand All @@ -934,6 +934,7 @@ describe('fetchBaseQuery', () => {
expect(res).toBeInstanceOf(Object)
expect(res.meta?.request).toBeInstanceOf(Request)
expect(res.meta?.response).toBeInstanceOf(Object)
expect(res.error).toBeUndefined()
expect(res.data).toEqual(`this is not json!`)
})

Expand Down

0 comments on commit 184fedd

Please sign in to comment.