src/client/createProxiedMethod.js
function doRequest(endpoint, payload, params, callback) {
  debug('Calling API endpoint: ' + endpoint + '.');

  request
    .post(endpoint)
    .send({ payload: payload })
    .set('Accept', 'application/json')
    .end(function(err, res) {
      if ((!res || !res.body) && !err) {
        err = new Error('No response from server. ' +
          '(Hint: Have you mounted isomorphine.router() in your app?)');
      }

      if (err) {
        return handleError(err, params, callback);
      }

      var values = res.body.values;

      if (!values || values.constructor !== Array) {
        err = new Error('Fetched payload is not an array.');
        return handleError(err, params, callback);
      }

      debug('Resolving callback with ' + JSON.stringify(values, null, 3));

      // Sets the error argument to null
      values.unshift(null);

      callback.apply(this, values);
    });
}
function doRequest(endpoint, payload, params, callback) {
  debug('Calling API endpoint: ' + endpoint + '.');

  request
    .post(endpoint)
    .send({ payload: payload })
    .set('Accept', 'application/json')
    .end(function(err, res) {
      if ((!res || !res.body) && !err) {
        err = new Error('No response from server. ' +
          '(Hint: Have you mounted isomorphine.router() in your app?)');
      }

      if (err) {
        return handleError(err, params, callback);
      }

      var values = res.body.values;

      if (!values || values.constructor !== Array) {
        err = new Error('Fetched payload is not an array.');
        return handleError(err, params, callback);
      }

      debug('Resolving callback with ' + JSON.stringify(values, null, 3));

      // Sets the error argument to null
      values.unshift(null);

      callback.apply(this, values);
    });
}
function doRequest ( endpoint , payload , params , callback ) { debug ( 'Calling API endpoint: ' + endpoint + '.' ) ; request . post ( endpoint ) . send ( { payload : payload } ) . set ( 'Accept' , 'application/json' ) . end ( function ( err , res ) { if ( ( ! res || ! res . body ) && ! err ) { err = new Error ( 'No response from server. ' + '(Hint: Have you mounted isomorphine.router() in your app?)' ) ; } if ( err ) { return handleError ( err , params , callback ) ; } var values = res . body . values ; if ( ! values || values . constructor !== Array ) { err = new Error ( 'Fetched payload is not an array.' ) ; return handleError ( err , params , callback ) ; } debug ( 'Resolving callback with ' + JSON . stringify ( values , null , 3 ) ) ; // Sets the error argument to null values . unshift ( null ) ; callback . apply ( this , values ) ; } ) ; }
Runs a request to an isomorphine's endpoint with the provided payload.

@param  {String}   endpoint  The endpoint to request.
@param  {Array}    payload   The arguments to send.
@param  {Object}   params    The server's configuration and error handlers.
@param  {Function} callback  The callback function to call afterwards.
Runs a request to an isomorphine s endpoint with the provided payload .