Skip to content

Instantly share code, notes, and snippets.

@tangorri
Created August 19, 2013 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tangorri/6270927 to your computer and use it in GitHub Desktop.
Save tangorri/6270927 to your computer and use it in GitHub Desktop.
how to get AuthService called before ?
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'] = 'jcpraud@ezakus.com';
$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