Use-case for requestError http interceptor

angularjs

Solution

One interesting use case is to tear down / undo things that have been set up before a request, and would have been teared down after a response. Examples:

- loading indicator

- overlay

- disabled form fields

Now when the request can't be sent or is rejected by another interceptor, `requestError` gives you the chance to act appropriately and remove that loading indicator or enable the form fields.

Problem

According to http://docs.angularjs.org/api/ng.$http an interceptor has following methods: ``` request: function(config) { //we could manipulate query here return config || $q.when(config); }, requestError: function(rejection) { // what is the use case of this? return $q.reject(rejection); }, response: function(response) { // response.status === 200 return response || $q.when(response); }, responseError: function(rejection) { // when response failed ... return $q.reject(rejection); } ``` How is `requestError` triggered and what use-cases can you think of?

Original source