Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 4
    Need to return $q.reject(response); when status == 401, to avoid a noisy angular error Commented Jul 29, 2013 at 1:40
  • 1
    @daniellmb. It depends. If you actually want to go to another page, not just change the view then you should actually use $window. If your login page is just another view and controller with your angular then you can use $location.path Commented Oct 3, 2013 at 13:18
  • 1
    @uriDium right my point was to use the angular provided objects so you can mock and test. Commented Oct 4, 2013 at 22:58
  • 22
    $httpProvider.responseInterceptors is now deprecated. See docs.angularjs.org/api/ng.$http#description_interceptors. Commented Feb 12, 2014 at 17:45
  • 1
    In success you need to return like return response || $q.when(response); so that if the response is empty then also a promise object is returned. Commented Feb 20, 2015 at 11:20