File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,11 @@ export const fetchToAxiosConfig = (
8787} ;
8888
8989export function axiosToFetchResponse ( axiosRes : AxiosResponse ) : Response {
90- const { data, status, statusText, headers : rawHeaders } = axiosRes ;
90+ const { data, status, statusText, config } = axiosRes ;
91+
92+ const headersObj = Object . fromEntries (
93+ Object . entries ( config . headers ) . map ( ( [ key , value ] ) => [ key , String ( value ) ] )
94+ ) ;
9195
9296 let body : BodyInit ;
9397 let contentType = "application/json" ;
@@ -98,15 +102,11 @@ export function axiosToFetchResponse(axiosRes: AxiosResponse): Response {
98102 data instanceof ArrayBuffer
99103 ) {
100104 body = data ;
101- contentType = rawHeaders [ "content-type" ] || "application/octet-stream" ;
105+ contentType = config . headers [ "content-type" ] || "application/octet-stream" ;
102106 } else {
103107 body = JSON . stringify ( data ) ;
104108 }
105109
106- const headersObj = Object . fromEntries (
107- Object . entries ( rawHeaders ) . map ( ( [ key , value ] ) => [ key , String ( value ) ] )
108- ) ;
109-
110110 if ( ! headersObj [ "content-type" ] ) {
111111 headersObj [ "content-type" ] = contentType ;
112112 }
You can’t perform that action at this time.
0 commit comments