How to use the superagent.serializeObject function in superagent

To help you get started, we’ve selected a few superagent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github keen / keen-js / src / core / helpers / superagent-request-types.js View on Github external
__super__.call(self, fn);
        return;
      }

      query = self._query.join('&');
      timeout = self._timeout;
      // store callback
      self._callback = fn || noop;
      // timeout
      if (timeout && !self._timer) {
        self._timer = setTimeout(function(){
          cancelRequest.call(self);
        }, timeout);
      }
      if (query) {
        query = superagent.serializeObject(query);
        self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
      }
      // send stuff
      self.emit('request', self);

      if ( !self.requestType['options'].async ) {
        sendXhrSync.call(self);
      }
      else if ( reqType === 'jsonp' ) {
        sendJsonp.call(self);
      }
      else if ( reqType === 'beacon' ) {
        sendBeacon.call(self);
      }
      return self;
    };
github smclab / ti-superagent / titanium.js View on Github external
// timeout
  if (timeout) {
    xhr.timeout = timeout;
  }

  if (redirects != null) {
    this.redirects(redirects);
  }

  if (validatesSecureCertificate != null) {
    xhr.validatesSecureCertificate = this._validatesSecureCertificate
  }

  // querystring
  if (query) {
    query = request.serializeObject(query);
    this.url += ~this.url.indexOf('?')
      ? '&' + query
      : '?' + query;
  }

  // initiate request
  xhr.open(this.method, this.url, true);

  // CORS
  if (this._withCredentials) xhr.withCredentials = true;

  // body
  if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
    // serialize stuff
    var serialize = request.serialize[this.getHeader('Content-Type')];
    if (serialize) data = serialize(data);
github keen / keen-js / dist / keen-tracker.js View on Github external
query,
          timeout;
      if ( ('GET' !== self['method'] ||  reqType === 'xhr' ) && self.requestType['options'].async ) {
        __super__.call(self, fn);
        return;
      }
      query = self._query.join('&');
      timeout = self._timeout;
      self._callback = fn || noop;
      if (timeout && !self._timer) {
        self._timer = setTimeout(function(){
          cancelRequest.call(self);
        }, timeout);
      }
      if (query) {
        query = superagent.serializeObject(query);
        self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
      }
      self.emit('request', self);
      if ( !self.requestType['options'].async ) {
        sendXhrSync.call(self);
      }
      else if ( reqType === 'jsonp' ) {
        sendJsonp.call(self);
      }
      else if ( reqType === 'beacon' ) {
        sendBeacon.call(self);
      }
      return self;
    };
    return request;
github zen-audio-player / zen-audio-player.github.io / bower_components / keen-js / dist / keen-query.js View on Github external
query,
          timeout;
      if ( ('GET' !== self['method'] ||  reqType === 'xhr' ) && self.requestType['options'].async ) {
        __super__.call(self, fn);
        return;
      }
      query = self._query.join('&');
      timeout = self._timeout;
      self._callback = fn || noop;
      if (timeout && !self._timer) {
        self._timer = setTimeout(function(){
          abortRequest.call(self);
        }, timeout);
      }
      if (query) {
        query = superagent.serializeObject(query);
        self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
      }
      self.emit('request', self);
      if ( !self.requestType['options'].async ) {
        sendXhrSync.call(self);
      }
      else if ( reqType === 'jsonp' ) {
        sendJsonp.call(self);
      }
      else if ( reqType === 'beacon' ) {
        sendBeacon.call(self);
      }
      return self;
    };
    return request;
github keen / keen-js / dist / keen-query.js View on Github external
query,
          timeout;
      if ( ('GET' !== self['method'] ||  reqType === 'xhr' ) && self.requestType['options'].async ) {
        __super__.call(self, fn);
        return;
      }
      query = self._query.join('&');
      timeout = self._timeout;
      self._callback = fn || noop;
      if (timeout && !self._timer) {
        self._timer = setTimeout(function(){
          cancelRequest.call(self);
        }, timeout);
      }
      if (query) {
        query = superagent.serializeObject(query);
        self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
      }
      self.emit('request', self);
      if ( !self.requestType['options'].async ) {
        sendXhrSync.call(self);
      }
      else if ( reqType === 'jsonp' ) {
        sendJsonp.call(self);
      }
      else if ( reqType === 'beacon' ) {
        sendBeacon.call(self);
      }
      return self;
    };
    return request;
github zen-audio-player / zen-audio-player.github.io / bower_components / keen-js / dist / keen-tracker.js View on Github external
query,
          timeout;
      if ( ('GET' !== self['method'] ||  reqType === 'xhr' ) && self.requestType['options'].async ) {
        __super__.call(self, fn);
        return;
      }
      query = self._query.join('&');
      timeout = self._timeout;
      self._callback = fn || noop;
      if (timeout && !self._timer) {
        self._timer = setTimeout(function(){
          abortRequest.call(self);
        }, timeout);
      }
      if (query) {
        query = superagent.serializeObject(query);
        self.url += ~self.url.indexOf('?') ? '&' + query : '?' + query;
      }
      self.emit('request', self);
      if ( !self.requestType['options'].async ) {
        sendXhrSync.call(self);
      }
      else if ( reqType === 'jsonp' ) {
        sendJsonp.call(self);
      }
      else if ( reqType === 'beacon' ) {
        sendBeacon.call(self);
      }
      return self;
    };
    return request;