lib/events.js
function (opts, callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 ) {
        if (this.status == 204){
          //success
          return callback(null);
        }else {
          return callback(this.statusText);
        }
      }
    };

    xhttp.open(opts.method, opts.host + '/' + opts.path, true);
    for (var header in opts.headers){
      var headerValue = opts.headers[header];
      xhttp.setRequestHeader(header, headerValue)
    }
    xhttp.send(opts.body);
  }
function (opts, callback) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 ) {
        if (this.status == 204){
          //success
          return callback(null);
        }else {
          return callback(this.statusText);
        }
      }
    };

    xhttp.open(opts.method, opts.host + '/' + opts.path, true);
    for (var header in opts.headers){
      var headerValue = opts.headers[header];
      xhttp.setRequestHeader(header, headerValue)
    }
    xhttp.send(opts.body);
  }
function ( opts , callback ) { var xhttp = new XMLHttpRequest ( ) ; xhttp . onreadystatechange = function ( ) { if ( this . readyState == 4 ) { if ( this . status == 204 ) { //success return callback ( null ) ; } else { return callback ( this . statusText ) ; } } } ; xhttp . open ( opts . method , opts . host + '/' + opts . path , true ) ; for ( var header in opts . headers ) { var headerValue = opts . headers [ header ] ; xhttp . setRequestHeader ( header , headerValue ) } xhttp . send ( opts . body ) ; }
Wraps the request function for easier testing
Make an http request and invoke a callback
@private
@param {Object} opts options describing the http request to be made
@param {Function} callback the callback to invoke when the http request is completed
Wraps the request function for easier testing Make an http request and invoke a callback