1

I'm getting the error: Circular dependency found: $http <- Auth <- $http <- Me.

This happens when I add Auth factory to my $httpProvider.interceptors as a dependency. I need to use Auth there for token refresh.

I do not understand the issue enough to fix it (despite reading this post and Miško Hevery's blog post... namely not sure how class C was introduced to the mix, but think it's somehow related to my Me dependency)

app.js:

.config([
    ...
    $httpProvider.interceptors.push(['Auth',...
       Auth.refreshToken();

Auth.js:

angular.module('DDE')
    .factory('Auth', ['$http', function($http) {

Me.js:

angular.module('DDE')
    .factory('Me', ['$http', 'Auth', function($http, Auth) {
Community
  • 1
  • 1
user3871
  • 12,432
  • 33
  • 128
  • 268
  • Did you read this answer ~ http://stackoverflow.com/a/19368367/283366 ? – Phil Jun 21 '16 at 03:27
  • 1
    this isn't directly related to `Me`. It is related to `Auth` needing `$http` in order to be initialized, while `$http` needs `Auth` because of the interceptor. `Me` is the one generating the error, because it doesn't know which one of these should be instantiated first, and really neither of them can be instantiated without the other. You will most likely need to move the `refreshToken()` function to a new module that both can access but doesn't depend on either of the existing modules. – Claies Jun 21 '16 at 03:47

0 Answers0