lib/Stateless.js
function postRequest(at, api_url, config, callback) {

  var r_opts = {
    uri:    getURL(at, api_url),
    method: 'POST',
    headers: {'Content-Type': 'application/json'}
  };

  if (config.body && !config.form) {
    r_opts.body = JSON.stringify(config.body);
  } else {
    r_opts.form = config.form;
  }

  if (!config.responseCode)
    config.responseCode = 200;

  request(
    r_opts,
    function(err,res,body) {
      if (!err && res.statusCode == config.responseCode) {
        if (config.doParse) {
          callback(null,JSON.parse(body).response);    
        } else {
          callback(null,res.statusCode);         
        }
      } else  {
        callback(res)
      }
  });    

}
function postRequest(at, api_url, config, callback) {

  var r_opts = {
    uri:    getURL(at, api_url),
    method: 'POST',
    headers: {'Content-Type': 'application/json'}
  };

  if (config.body && !config.form) {
    r_opts.body = JSON.stringify(config.body);
  } else {
    r_opts.form = config.form;
  }

  if (!config.responseCode)
    config.responseCode = 200;

  request(
    r_opts,
    function(err,res,body) {
      if (!err && res.statusCode == config.responseCode) {
        if (config.doParse) {
          callback(null,JSON.parse(body).response);    
        } else {
          callback(null,res.statusCode);         
        }
      } else  {
        callback(res)
      }
  });    

}
function postRequest ( at , api_url , config , callback ) { var r_opts = { uri : getURL ( at , api_url ) , method : 'POST' , headers : { 'Content-Type' : 'application/json' } } ; if ( config . body && ! config . form ) { r_opts . body = JSON . stringify ( config . body ) ; } else { r_opts . form = config . form ; } if ( ! config . responseCode ) config . responseCode = 200 ; request ( r_opts , function ( err , res , body ) { if ( ! err && res . statusCode == config . responseCode ) { if ( config . doParse ) { callback ( null , JSON . parse ( body ) . response ) ; } else { callback ( null , res . statusCode ) ; } } else { callback ( res ) } } ) ; }
This makes one of many different types of post requests. config.body         - this stingifies the object as the POST body config.form         - this sets the POST body as form parameters config.doParse      - if true,  parses the return value as json config.responseCode - if set, checks for this response code
This makes one of many different types of post requests . config . body - this stingifies the object as the POST body config . form - this sets the POST body as form parameters config . doParse - if true parses the return value as json config . responseCode - if set checks for this response code