Skip to content

Commit a9abb1d

Browse files
phryneasmarkerikson
authored andcommitted
remove unnecessary fetchBaseQuery defaults
1 parent 85ec86b commit a9abb1d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

packages/toolkit/src/query/fetchBaseQuery.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export type FetchBaseQueryMeta = { request: Request; response?: Response }
184184
* @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`.
185185
*
186186
* @param {(this: any, key: string, value: any) => any} jsonReplacer Custom replacer function used when calling `JSON.stringify()`.
187-
*
187+
*
188188
* @param {number} timeout
189189
* A number in milliseconds that represents the maximum time a request can take before timing out.
190190
*/
@@ -216,9 +216,7 @@ export function fetchBaseQuery({
216216
let meta: FetchBaseQueryMeta | undefined
217217
let {
218218
url,
219-
method = 'GET' as const,
220219
headers = new Headers(baseFetchOptions.headers),
221-
body = undefined,
222220
params = undefined,
223221
responseHandler = 'json' as const,
224222
validateStatus = globalValidateStatus ?? defaultValidateStatus,
@@ -227,9 +225,7 @@ export function fetchBaseQuery({
227225
} = typeof arg == 'string' ? { url: arg } : arg
228226
let config: RequestInit = {
229227
...baseFetchOptions,
230-
method,
231228
signal,
232-
body,
233229
...rest,
234230
}
235231

@@ -250,12 +246,12 @@ export function fetchBaseQuery({
250246
Array.isArray(body) ||
251247
typeof body.toJSON === 'function')
252248

253-
if (!config.headers.has('content-type') && isJsonifiable(body)) {
249+
if (!config.headers.has('content-type') && isJsonifiable(config.body)) {
254250
config.headers.set('content-type', jsonContentType)
255251
}
256252

257-
if (isJsonifiable(body) && isJsonContentType(config.headers)) {
258-
config.body = JSON.stringify(body, jsonReplacer)
253+
if (isJsonifiable(config.body) && isJsonContentType(config.headers)) {
254+
config.body = JSON.stringify(config.body, jsonReplacer)
259255
}
260256

261257
if (params) {

0 commit comments

Comments
 (0)