Reputation: 59
I'm developping an application using javascript angularJS library at client side and spring framework (java) for back-end implementation. For one of the services I return a parameter in Response Header. The issue is I cannot get this value after the service call.
This is the factory:
angular.module('app')
.factory('financeDocumentService', ['$resource', 'SERVER_FOR_SERVICES',
function ($resource, SERVER_FOR_SERVICES) {
var url = SERVER_FOR_SERVICES + '/sapi/finance/document';
return $resource(url + '/:id', {id: '@id'}, {
'get': {method: 'GET'},
'isReferencedDocumentIdCompensated':
{
method: 'GET',
isArray: false,
url: url + '/is_compensated?referenced_document_id=:id',
params: {id: '@id'},
headers: {'Access-Control-Expose-Headers': 'IsCompensated'},
transformResponse: function (data, headers) {
response = {};
response.data = data;
response.headers = headers();
console.log(headers());
return response;
}
}
});
}]);
This is the code at controller:
$scope.flightRecords[i].financeDocument =
financeDocumentService
.isReferencedDocumentIdCompensated(
{id: $scope.flightRecords[i].id}).$promise.then(
function(data) {
console.log(data.headers);
}
);
This is the result:
Object { cache-control: "no-cache, no-store, max-age=0, must…", pragma: "no-cache", expires: "0" }
And this is the header list values:
Access-Control-Allow-Origin: http://localhost:8383
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 0
Date: Thu, 29 Jun 2017 18:19:23 GMT
Expires: 0
Pragma: no-cache
Vary: Origin
X-Application-Context: application:local
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
access-control-allow-credentials: true
isCompensated: false
x-content-type-options: nosniff
Thanks a lot!
Upvotes: 0
Views: 49