久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

從 JSON 響應訪問 [Symbol(Response internals)]

Accessing [Symbol(Response internals)] from JSON response(從 JSON 響應訪問 [Symbol(Response internals)])
本文介紹了從 JSON 響應訪問 [Symbol(Response internals)]的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在使用庫 isomorphic-unfetch (https:///www.npmjs.com/package/isomorphic-unfetch) 從 Rest API 獲取 JSON 數據.這就是我提出請求的方式:

I'm using the library isomorphic-unfetch (https://www.npmjs.com/package/isomorphic-unfetch) to get JSON data from a Rest API. This is how I make the request:

    const res = await fetch(
      `url`
    );

要訪問正文,我只需要這樣做

To access the body I simply need to do

    const response = await res.json()

但是如何訪問響應標頭?如果我將響應記錄到我的服務器控制臺,這就是我所看到的:

But how do I access the response headers? If I log the response to my server's console this is what I see:

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    // stuff
  },
  [Symbol(Response internals)]: {
    url: 'request url',
    status: 200,
    statusText: 'OK',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

什么是符號(響應內部)?以及如何訪問它的 headers 屬性?

What's Symbol(Response internals)? And how do I access its headers property?

推薦答案

要訪問其 headers,請使用以下方法之一:

To access its headers use one of the following:

const res = await fetch(url);
console.log(res.headers.get('content-type');
// or
res.headers.forEach(header => console.log(header));

https://github.github.io/fetch/#Headers

這篇關于從 JSON 響應訪問 [Symbol(Response internals)]的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監視函數中的函數調用?)
主站蜘蛛池模板: 日韩在线一区二区三区 | 欧美精品日韩精品国产精品 | 91美女视频 | 欧美精品一区在线 | 99亚洲精品 | 四虎在线观看 | 日韩精品在线免费观看视频 | 精品亚洲一区二区 | 国产亚洲成av人片在线观看桃 | 精品久久久久久亚洲综合网 | 日韩激情免费 | 91精品在线播放 | 日本成人三级电影 | 午夜影视免费片在线观看 | 综合色在线 | 国产精品女人久久久 | 国产xxxx搡xxxxx搡麻豆 | 日韩精品一区二区三区 | 国产视频一二三区 | 成人在线视频免费播放 | 在线观看中文字幕 | 天天躁日日躁狠狠很躁 | 亚洲精品视频免费看 | 国产精品毛片久久久久久久 | 国产亚洲一区二区精品 | 狠狠干av| 天天干天天爱天天 | 中文字幕专区 | 91av免费观看| 毛片大全 | 一区二区高清 | 国产三级日本三级 | 日韩欧美一区二区在线播放 | 欧美亚洲视频 | 日韩精品a在线观看图片 | 久久久久国产精品一区三寸 | 一区二区三区久久 | 日韩在线一区二区 | 日本不卡免费新一二三区 | 国产成人精品av | 久久偷人|