src/lib/PumpupAPI.js
/**
   * ### _fetch
   * A function that prepares the request by
   * adding pumpup specific request options
   * like _method, _version, _SessionToken
   *
   * @returns object:
   *  {code: response.code,
   *   status: response.status,
   *   json: response.json()
   */
_fetch
A function that prepares the request by
adding pumpup specific request options
like _method, _version, _SessionToken


_fetch A function that prepares the request by adding pumpup specific request options like _method _version _SessionToken
async _fetch (opts) {
    opts = _.extend({
      method: 'GET',
      url: null,
      callback: null
    }, opts)
    let reqOpts = {
      method: 'POST',
      headers: {
      }
    }
    if (opts.method === 'POST' || opts.method === 'PUT') {
      reqOpts.headers.Accept = 'application/json'
      reqOpts.headers['Content-Type'] = 'application/json'
    }
    if (opts.body) {
      reqOpts.body = JSON.stringify(opts.body)
    }
    let url = this.API_BASE_URL + opts.url
    let res = {}
    try {
      let response = await fetch(url, reqOpts)
      res.status = response.status
      res.code = response.code
      return response.json()
      .then((json) => {
        res.json = json
        return res
      })
    } catch(error) {
      console.error(error)
    }
  }
async _fetch ( opts ) { opts = _ . extend ( { method : 'GET' , url : null , callback : null } , opts ) let reqOpts = { method : 'POST' , headers : { } } if ( opts . method === 'POST' || opts . method === 'PUT' ) { reqOpts . headers . Accept = 'application/json' reqOpts . headers [ 'Content-Type' ] = 'application/json' } if ( opts . body ) { reqOpts . body = JSON . stringify ( opts . body ) } let url = this . API_BASE_URL + opts . url let res = { } try { let response = await fetch ( url , reqOpts ) res . status = response . status res . code = response . code return response . json ( ) . then ( ( json ) => { res . json = json return res } ) } catch ( error ) { console . error ( error ) } }
### _fetch
 A function that prepares the request by
 adding pumpup specific request options
 like _method, _version, _SessionToken
### _fetch A function that prepares the request by adding pumpup specific request options like _method _version _SessionToken
// console.log('response json is', json)