How to use the superagent.emit 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 wejendorp / angular-superagent / release / angular-superagent.js View on Github external
agent.Request.prototype.end = function(cb) {
        var request = this;

        request.emit('ngRequest');
        agent.emit('request');

        this._end(function(err, res) {
          request.emit('ngEnd');

          if(err) { agent.emit('error', err); }
          agent.emit('end', request);
          cb(err, res);
        });
      };
    });
github wejendorp / angular-superagent / index.js View on Github external
agent.Request.prototype.end = function(cb) {
        var request = this;

        request.emit('ngRequest');
        agent.emit('request');

        this._end(function(err, res) {
          request.emit('ngEnd');

          if(err) { agent.emit('error', err); }
          agent.emit('end', request);
          cb(err, res);
        });
      };
    });
github wejendorp / angular-superagent / release / angular-superagent.js View on Github external
this.end(function(err, res) {
          if(err) {
            agent.emit('error', err);
            err.method = request.method;
            err.url = request.url;
            err = $q.reject(err);
          }

          var resolution = requestProvider.resolvers.reduce(function(promise, resolvers) {
            var success = resolvers[0] ? resolvers[0].bind(methods) : null;
            var error   = resolvers[1] ? resolvers[1].bind(methods) : null;
            return promise.then(success, error);
          }, err || $q.when(res));

          deferred.resolve(resolution);
          $scope.$apply();
        });
github wejendorp / angular-superagent / index.js View on Github external
this.end(function(err, res) {
          if(err) {
            agent.emit('error', err);
            err.method = request.method;
            err.url = request.url;
            err = $q.reject(err);
          }

          var resolution = requestProvider.resolvers.reduce(function(promise, resolvers) {
            var success = resolvers[0] ? resolvers[0].bind(methods) : null;
            var error   = resolvers[1] ? resolvers[1].bind(methods) : null;
            return promise.then(success, error);
          }, err || $q.when(res));

          deferred.resolve(resolution);
          $scope.$apply();
        });
github wejendorp / angular-superagent / index.js View on Github external
this._end(function(err, res) {
          request.emit('ngEnd');

          if(err) { agent.emit('error', err); }
          agent.emit('end', request);
          cb(err, res);
        });
      };
github wejendorp / angular-superagent / release / angular-superagent.js View on Github external
this._end(function(err, res) {
          request.emit('ngEnd');

          if(err) { agent.emit('error', err); }
          agent.emit('end', request);
          cb(err, res);
        });
      };