angular-http-attach-promise

1.0.3 • Public • Published

angular-http-attach-promise

Build Status

npm install --save angular-http-attach-promise

Usage

Simply add it to your Http interceptors. A Promise will be will be attached at each request (if it doesn't specify the timeout field):

  /* in your angular.config phase */
  ...
  $httpProvider.interceptors.push('HttpAttachPromiseInterceptor')
  ...

And in your application code add some service that handles pending requests, ideally with $http.pendingRequests:

function RequestHandler($http) {
  this.cancelPending = function(){
    angular.forEach($http.pendingRequests, function(request) {
      if (request.cancel && request.timeout) {
        request.cancel.resolve()
      }
    })
  }
}

UMD

This is an UMD package.

License

Do whatever you please with this.

Readme

Keywords

none

Package Sidebar

Install

npm i angular-http-attach-promise

Weekly Downloads

6

Version

1.0.3

License

none

Last publish

Collaborators

  • christian_fei