function requestWithToken(options, params, body = {}, headers = {}, customToken = null, tokenType = 'Bearer') {
  const cloned = cloneDeep(options);
  if (params) { cloned.route = parameterizeRoute(cloned.route, params); }
  const requestHeaders = Object.assign({}, headers, {
    Authorization: (done) => {
      if (customToken !== null) {
        done(`${tokenType} ${customToken}`);
      } else {
        Storage.getToken(options.storageOveride).then((storedToken) => {
          done(`${tokenType} ${storedToken}`);
        });
      }
    },
  });
  return callRequest(cloned, body, requestHeaders);
}
function requestWithToken(options, params, body = {}, headers = {}, customToken = null, tokenType = 'Bearer') {
  const cloned = cloneDeep(options);
  if (params) { cloned.route = parameterizeRoute(cloned.route, params); }
  const requestHeaders = Object.assign({}, headers, {
    Authorization: (done) => {
      if (customToken !== null) {
        done(`${tokenType} ${customToken}`);
      } else {
        Storage.getToken(options.storageOveride).then((storedToken) => {
          done(`${tokenType} ${storedToken}`);
        });
      }
    },
  });
  return callRequest(cloned, body, requestHeaders);
}
function requestWithToken ( options , params , body = { } , headers = { } , customToken = null , tokenType = 'Bearer' ) { const cloned = cloneDeep ( options ) ; if ( params ) { cloned . route = parameterizeRoute ( cloned . route , params ) ; } const requestHeaders = Object . assign ( { } , headers , { Authorization : ( done ) => { if ( customToken !== null ) { done ( ` ${ tokenType } ${ customToken } ` ) ; } else { Storage . getToken ( options . storageOveride ) . then ( ( storedToken ) => { done ( ` ${ tokenType } ${ storedToken } ` ) ; } ) ; } } , } ) ; return callRequest ( cloned , body , requestHeaders ) ; }
Call a api request and set Auth header
@param  {Object} options - {method, token, route, external, form, headers}
@param  {Object} params
@param  {Object} body
@param  {Object} headers
@param  {String} customToken
Call a api request and set Auth header @param { Object } options - { method token route external form headers } @param { Object } params @param { Object } body @param { Object } headers @param { String } customToken