src/resource/Resource.js
/**
   * Actual request call. This method merges mandatory request options with
   * user provided ones and forces the resource path and API Key, so they are
   * not overriden. Serializes any body passed in, and deserializes response in
   * the end.
   *
   * Callback may be used in place of userOptions.
   *
   * @param {Settings} requestOptions - Mandatory request options
   * @param {Settings} [userOptions] - Optional user options
   * @param {Function} [callback] - Error-first callback
   * @returns {Promise.<Object|Entity|Response>}
   * @private
   */
Actual request call. This method merges mandatory request options with
user provided ones and forces the resource path and API Key, so they are
not overriden. Serializes any body passed in, and deserializes response in
the end.

Callback may be used in place of userOptions.


Actual request call . This method merges mandatory request options with user provided ones and forces the resource path and API Key so they are not overriden . Serializes any body passed in and deserializes response in the end . Callback may be used in place of userOptions .
async _request (requestOptions, userOptions = {}, callback) {
    if (isFunction(userOptions)) {
      callback = userOptions
    }
    const options = Object.assign({}, userOptions, requestOptions, {
      apiKey: this.scope.apiKey
    })
    if (options.body) {
      options.body = await this.serialize(options.body)
    }
    if (Object.keys(this.preParams).length) {
      Object.assign(options, { params: this.preParams })
      this.preParams = {}
    }
    try {
      const response = await api(options)
      const deserialized = await this.deserialize(response)
      return success(callback)(deserialized)
    } catch (err) {
      throw failure(callback)(err)
    }
  }
async _request ( requestOptions , userOptions = { } , callback ) { if ( isFunction ( userOptions ) ) { callback = userOptions } const options = Object . assign ( { } , userOptions , requestOptions , { apiKey : this . scope . apiKey } ) if ( options . body ) { options . body = await this . serialize ( options . body ) } if ( Object . keys ( this . preParams ) . length ) { Object . assign ( options , { params : this . preParams } ) this . preParams = { } } try { const response = await api ( options ) const deserialized = await this . deserialize ( response ) return success ( callback ) ( deserialized ) } catch ( err ) { throw failure ( callback ) ( err ) } }
Actual request call.
Actual request call .
// Merge options, priority to mandatory ones. // Serialize Entity into JSON payload. // Any preParams set? // Execute callback after deserialization.