Hi I am new to Angular JS, I am trying to put custom header in my $resource method, but I am not sure how would I do that Following is my code :
function userFactory($resource, API) {
return $resource(API + '/users/:cmd', {}, {}, {
login: {method: 'GET', params: {cmd: 'current'}, headers: headerParam},
get: {method: 'GET'},
create: {method: 'POST'}
}
);
I would like to add a custom header 'headerParam' based on which user has logged in since the header would contain username and password specific details.
As I look at the header documentation in $http.config. This is map of string\ function, which implies you can call a function to set specific header
Something like
headers:{credentials: getUserCredentials}
And in the factory you can create the above method.
I have not tried, see if it helps.