簡體   English   中英

AngularJS-獲取響應頭

[英]AngularJS - get headers in response

我正在對具有XML文件的https服務執行$http.get請求,它需要headers('Content-length')知道它的大小。

這是我的代碼:

$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);

});

請求的結果是: "headers is not a function" 還有另一種方法嗎?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM