File tree Expand file tree Collapse file tree 1 file changed +20
-20
lines changed
packages/toolkit/src/query Expand file tree Collapse file tree 1 file changed +20
-20
lines changed Original file line number Diff line number Diff line change @@ -42,26 +42,6 @@ const defaultValidateStatus = (response: Response) =>
4242const defaultIsJsonContentType = ( headers : Headers ) =>
4343 /*applicat*/ / i o n \/ ( v n d \. a p i \+ ) ? j s o n / . 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-
6545export 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}
You can’t perform that action at this time.
0 commit comments