Created
August 19, 2013 16:17
-
-
Save tangorri/6270927 to your computer and use it in GitHub Desktop.
how to get AuthService called before ?
This file contains hidden or 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
App.factory('AuthService', function($http) { | |
return $http({ | |
method: 'POST', | |
url: AUTHEN_BASE_URL, | |
data: AUTHEN_PARAMS, | |
headers: {'Content-Type': 'application/x-www-form-urlencoded'} | |
}) | |
.then( | |
function success(response) { | |
$http.defaults.headers.common['X-EZ-USER'] = '[email protected]'; | |
$http.defaults.headers.common['X-EZ-TOKEN'] = response.data.body; | |
auth = true; | |
console.log('token success get ' + response.data.body); | |
}, | |
function error(reason) { | |
console.error('error while loading token'); | |
} | |
); | |
}) | |
App.factory('Profile', function($http, AuthService) { | |
$http.get(BASE_URL + bid); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment