Last active
August 29, 2015 14:11
-
-
Save Alos/1822a906bd1a1467b48d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('Myapp' [ | |
]) | |
.factory ('Foo' , function(MyServiceThatUsesHTTP){ | |
var userDetails = {}; | |
userDetails.setToken(aToken){ | |
this.token = aToken; | |
} | |
userDetails.doSomething() = function(){ | |
MyServiceThatUsesHTTP.meh(); | |
}; | |
}) | |
.run(['', function(){ | |
//Here there by dragons | |
}]) | |
.config('', function(){ | |
//overwite the response interceptor here | |
$httpProvider.reponseInterceptors.push([ | |
'Foo', function(Foo){ /** PROBLEM because of this */ | |
//... | |
if(reponse.status ===401 && .......){ | |
//We need to get a new token and save it to our userDetails | |
$injector.get('$http').jsonp('/my_auth').then(function(response){ | |
if(response){ | |
Foo.setToken(response.mytoken); /** PROBLEM because of this */ | |
} | |
}); | |
.... | |
} | |
.... | |
}]) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment