Skip to content

Commit beec324

Browse files
committed
move handleResponse function into scope of fetchBaseQuery
1 parent 53befa6 commit beec324

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

packages/toolkit/src/query/fetchBaseQuery.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,6 @@ const defaultValidateStatus = (response: Response) =>
4242
const defaultIsJsonContentType = (headers: Headers) =>
4343
/*applicat*/ /ion\/(vnd\.api\+)?json/.test(headers.get('content-type') || '')
4444

45-
const handleResponse = async (
46-
response: Response,
47-
responseHandler: ResponseHandler
48-
) => {
49-
if (typeof responseHandler === 'function') {
50-
return responseHandler(response)
51-
}
52-
53-
if (responseHandler === 'content-type') {
54-
responseHandler = isJsonContentType(response.headers) ? 'json' : 'text'
55-
}
56-
57-
if (responseHandler === 'json') {
58-
const text = await response.text()
59-
return text.length ? JSON.parse(text) : null
60-
}
61-
62-
return response.text()
63-
}
64-
6545
export type FetchBaseQueryError =
6646
| {
6747
/**
@@ -345,4 +325,24 @@ export function fetchBaseQuery({
345325
meta,
346326
}
347327
}
328+
329+
async function handleResponse(
330+
response: Response,
331+
responseHandler: ResponseHandler
332+
) {
333+
if (typeof responseHandler === 'function') {
334+
return responseHandler(response)
335+
}
336+
337+
if (responseHandler === 'content-type') {
338+
responseHandler = isJsonContentType(response.headers) ? 'json' : 'text'
339+
}
340+
341+
if (responseHandler === 'json') {
342+
const text = await response.text()
343+
return text.length ? JSON.parse(text) : null
344+
}
345+
346+
return response.text()
347+
}
348348
}

0 commit comments

Comments
 (0)