File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 7171 "react-redux" : " ^6.0.1" ,
7272 "react-router-dom" : " ^5.0.0" ,
7373 "redux" : " ^4.0.1" ,
74- "urijs" : " ^1.19.1 "
74+ "urijs" : " ^1.19.4 "
7575 },
7676 "devDependencies" : {
7777 "@babel/core" : " 7.4.3" ,
Original file line number Diff line number Diff line change @@ -175,6 +175,8 @@ export class API {
175175
176176 const headers = {
177177 'content-type' : 'application/json' ,
178+
179+
178180 } ;
179181
180182 if ( this . token && this . token . token ) {
@@ -186,20 +188,27 @@ export class API {
186188 url : this . route ( opts ) ,
187189 params : query ,
188190 headers,
189- transformResponse : [ ] ,
191+ transformResponse : [ function transformResponse ( data , headers ) {
192+ if ( typeof data === 'string' && headers [ "content-type" ] === "application/json" ) {
193+ try {
194+ data = JSON . parse ( data ) ;
195+ } catch ( e ) { /* Ignore */ }
196+ }
197+ return data ;
198+ }
199+ ] ,
190200 data,
191201 withCredentials : true ,
192202 paramsSerializer : params => {
193203 params = _ . mapValues ( params , param => {
194204 if ( _ . isArray ( param ) ) {
195205 return param . join ( ',' ) ;
196206 }
197-
198207 return param ;
199208 } ) ;
200-
201209 return buildURL ( '' , params ) . substr ( 1 ) ;
202210 } ,
211+ // responseType: 'json',
203212 } ;
204213
205214 if ( this . rejectUnauthorized === false ) {
@@ -210,7 +219,6 @@ export class API {
210219 }
211220
212221 const response = await axios ( config ) ;
213-
214222 const contentType = ( response . headers || { } ) [ 'content-type' ] || [ ] ;
215223 const requestId = ( response . headers || { } ) [ 'X-Request-ID' ] || null ;
216224
Original file line number Diff line number Diff line change 3030 "lodash" : " 4.17.19" ,
3131 "react" : " 16.8.6" ,
3232 "react-dom" : " 16.8.6" ,
33- "axios" : " ^0.18.0 " ,
33+ "axios" : " ^0.21.1 " ,
3434 "moxios" : " ^0.4.0"
3535 },
3636 "devDependencies" : {
Original file line number Diff line number Diff line change 8585 "react-redux" : " 7.0.2" ,
8686 "redux" : " ^4.0.1" ,
8787 "set-value" : " ^2.0.1" ,
88- "urijs" : " 1.19.4" ,
88+ "urijs" : " ^ 1.19.4" ,
8989 "websocket-extensions" : " ^0.1.4"
9090 },
9191 "devDependencies" : {
You can’t perform that action at this time.
0 commit comments