From a9abb1d6213148728e340b4e84e7d3a762902395 Mon Sep 17 00:00:00 2001 From: Lenz Weber Date: Fri, 6 Jan 2023 16:14:36 +0100 Subject: [PATCH] remove unnecessary fetchBaseQuery defaults --- packages/toolkit/src/query/fetchBaseQuery.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/toolkit/src/query/fetchBaseQuery.ts b/packages/toolkit/src/query/fetchBaseQuery.ts index d3dbfb21af..2fa4c5905b 100644 --- a/packages/toolkit/src/query/fetchBaseQuery.ts +++ b/packages/toolkit/src/query/fetchBaseQuery.ts @@ -184,7 +184,7 @@ export type FetchBaseQueryMeta = { request: Request; response?: Response } * @param {string} jsonContentType Used when automatically setting the content-type header for a request with a jsonifiable body that does not have an explicit content-type header. Defaults to `application/json`. * * @param {(this: any, key: string, value: any) => any} jsonReplacer Custom replacer function used when calling `JSON.stringify()`. - * + * * @param {number} timeout * A number in milliseconds that represents the maximum time a request can take before timing out. */ @@ -216,9 +216,7 @@ export function fetchBaseQuery({ let meta: FetchBaseQueryMeta | undefined let { url, - method = 'GET' as const, headers = new Headers(baseFetchOptions.headers), - body = undefined, params = undefined, responseHandler = 'json' as const, validateStatus = globalValidateStatus ?? defaultValidateStatus, @@ -227,9 +225,7 @@ export function fetchBaseQuery({ } = typeof arg == 'string' ? { url: arg } : arg let config: RequestInit = { ...baseFetchOptions, - method, signal, - body, ...rest, } @@ -250,12 +246,12 @@ export function fetchBaseQuery({ Array.isArray(body) || typeof body.toJSON === 'function') - if (!config.headers.has('content-type') && isJsonifiable(body)) { + if (!config.headers.has('content-type') && isJsonifiable(config.body)) { config.headers.set('content-type', jsonContentType) } - if (isJsonifiable(body) && isJsonContentType(config.headers)) { - config.body = JSON.stringify(body, jsonReplacer) + if (isJsonifiable(config.body) && isJsonContentType(config.headers)) { + config.body = JSON.stringify(config.body, jsonReplacer) } if (params) {