File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -507,7 +507,10 @@ var Client = module.exports = function(config) {
507
507
508
508
var ret ;
509
509
try {
510
- ret = res . data && JSON . parse ( res . data ) ;
510
+ ret = res . data ;
511
+ var contentType = res . headers [ "content-type" ] ;
512
+ if ( contentType && contentType . indexOf ( "application/json" ) !== - 1 )
513
+ ret = JSON . parse ( ret ) ;
511
514
}
512
515
catch ( ex ) {
513
516
if ( callback )
@@ -517,12 +520,14 @@ var Client = module.exports = function(config) {
517
520
518
521
if ( ! ret )
519
522
ret = { } ;
520
- if ( ! ret . meta )
521
- ret . meta = { } ;
522
- [ "x-ratelimit-limit" , "x-ratelimit-remaining" , "link" ] . forEach ( function ( header ) {
523
- if ( res . headers [ header ] )
524
- ret . meta [ header ] = res . headers [ header ] ;
525
- } ) ;
523
+ if ( typeof ret == "object" ) {
524
+ if ( ! ret . meta )
525
+ ret . meta = { } ;
526
+ [ "x-ratelimit-limit" , "x-ratelimit-remaining" , "link" ] . forEach ( function ( header ) {
527
+ if ( res . headers [ header ] )
528
+ ret . meta [ header ] = res . headers [ header ] ;
529
+ } ) ;
530
+ }
526
531
527
532
if ( callback )
528
533
callback ( null , ret ) ;
You can’t perform that action at this time.
0 commit comments