7
我正在使用$ resource從我的RESTful服務獲取數據,並且需要讀取響應標題才能獲得分頁的「X-Page」和「X-Total-Pages」值。
例子:
Access-Control-Max-Age:1728000
Cache-Control:max-age=0, private, must-revalidate
Connection:Keep-Alive
Content-Length:2637
Content-Type:application/json
Date:Thu, 10 Apr 2014 16:53:01 GMT
Server:WEBrick/1.3.1 (Ruby/2.1.1/2014-02-24)
Vary:Origin
X-Page:1
X-Per-Page:10
X-Total:17
X-Total-Pages:2
但我無法從服務器獲取完整標題。
這是我的代碼:
.factory('TestAPI', ['$resource',
function ($resource) {
return $resource("http://ip.jsontest.com/?callback=showIP", {}, {
query: {
method: 'GET'
}
});
}])
TestAPI.query({}, function (value, responseHeaders) {
console.log(responseHeaders());
}, function (response) {
console.log(response);
});
但是如何讀取它的角? –
這救了我的命!非常感謝你。 –
請問如何獲得相關幫助 –