Currently, I am working with Ionic 1.3 and Angular 1.5.
My goal is to retrieve some header properties from my response. The code snippet I am using looks something like this:
factory('Service', function($resource, API_SETTINGS, JsonData) {
return $resource('/users/path', {}, {
'fetch': {
method: 'GET',
headers: {
Authorization: 'Bearer'
},
transformResponse: function(data, headersGetter, status) {
if (data) {
data = JSON.parse(data);
return {
data: data,
headers: headersGetter()
};
}
}
}
});
})
The values for the headers are as follows:
{
cache-control: 'max-age=0, private, must-revalidate',
content-type: 'application/json; charset=utf-8'
}
Despite having set up the 'Access-Control-Expose-Headers: X-User-Count' in both the server and within the $resource headers object, I still cannot access the X-User-Count property that I need.
I have even tried using a Chrome extension to toggle CORS, but unfortunately, it hasn't made any difference. Although I have checked multiple Stack Overflow posts on this issue, none of them seem to provide relevant solutions.
If anyone has any advice or suggestions on how to tackle this problem, I would greatly appreciate your input!