我在使用chrome 52.0.2743.82(64位)進行提取。我想獲得響應中的所有標題。以下片段僅返回content-type
,但如果您瀏覽chrome開發工具,則會顯示許多其他響應標頭。如何獲取其他標題。如何從提取中獲取響應的標題
fetch('https://httpbin.org/get')
.then(response => {
const headers = response.headers.entries();
let header = headers.next();
while (!header.done){
console.log(headers.value);
header = header.next();
}
})
我嘗試了polyfilling(手動覆蓋)github實現。仍然沒有運氣。
如果你知道你正在尋找什麼頭,你可以嘗試response.headers.get('header-name') – KumarM
看看這個頁面底部的兼容性表,它並沒有說鉻支持條目()然而。 https://developer.mozilla.org/en-US/docs/Web/API/Headers – KumarM