@@ -4,7 +4,7 @@ import * as buildURL from "axios/lib/helpers/buildURL"
44import * as querystring from "querystring"
55import { cloneSafe } from "./utils"
66
7- function cleanObject ( o : { string : any } ) {
7+ function cleanObject ( o : { string : any } ) {
88 for ( const k in o || { } ) {
99 if ( typeof o [ k ] === "undefined" ) {
1010 delete o [ k ]
@@ -19,7 +19,7 @@ function removeSearchFromUrl(config: AxiosRequestConfig) {
1919 const queryString = url . search . substr ( 1 )
2020 if ( queryString ) {
2121 // https://stackoverflow.com/a/8649003/387413
22- const urlParams = JSON . parse ( '{"' + queryString . replace ( / & / g, '","' ) . replace ( / = / g, '":"' ) + '"}' , function ( key , value ) {
22+ const urlParams = JSON . parse ( '{"' + queryString . replace ( / & / g, '","' ) . replace ( / = / g, '":"' ) + '"}' , function ( key , value ) {
2323 return key === "" ? value : decodeURIComponent ( value )
2424 } )
2525 for ( const k in urlParams ) {
@@ -43,7 +43,7 @@ function oauth1ParamsSerializer(p: any) {
4343}
4444
4545// XXX warn about mutating config object... or clone?
46- export default async function ( step : any , config : AxiosRequestConfig , signConfig ?: any ) {
46+ export default async function ( step : any , config : AxiosRequestConfig , signConfig ?: any ) {
4747 cleanObject ( config . headers )
4848 cleanObject ( config . params )
4949 if ( typeof config . data === "object" ) {
@@ -52,7 +52,7 @@ export default async function(step: any, config: AxiosRequestConfig, signConfig?
5252 removeSearchFromUrl ( config )
5353 // OAuth1 request
5454 if ( signConfig ) {
55- const { oauthSignerUri, token} = signConfig
55+ const { oauthSignerUri, token } = signConfig
5656 const requestData = {
5757 method : config . method || "get" ,
5858 url : buildURL ( config . url , config . params , oauth1ParamsSerializer ) , // build url as axios will
@@ -84,7 +84,13 @@ export default async function(step: any, config: AxiosRequestConfig, signConfig?
8484 try {
8585 return ( await axios ( config ) ) . data
8686 } catch ( err ) {
87- if ( err . response ) step . debug = cloneSafe ( err . response )
88- throw err
87+ if ( err . response ) {
88+ if ( step . export ) {
89+ step . export ( "debug" , cloneSafe ( err . response ) )
90+ } else {
91+ step . debug = cloneSafe ( err . response )
92+ }
93+ throw err
94+ }
8995 }
9096}
0 commit comments