Franco Manzur Franco Manzur - 5 months ago 9
Javascript Question

AngularJS - get headers in response

I'm doing a

$http.get
request to a https service which has an XML file and it need the
headers('Content-length')
to know it size.

This's my code:

$http({
method : "GET",
url : "https://url.com/xml_file.xml"
}).then(
function sCallback(data, status, headers, config, statusText) {

console.log( headers('Content-Length') );

}, function eCallback(data, status, headers, config, statusText) {

$log.warn(data, status, headers, config, statusText);

});


The result of the request is:
"headers is not a function"
.
Is there another way to get it?

Answer

 console.log( data.headers('Content-Length'));
 console.log( data.headers('Content-type'));

Comments