此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Request.bodyUsed

基线 广泛可用

自 2017年3月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

Request 接口的只读属性 bodyUsed 是一个布尔值,表示请求体是否已经被读取。

一个布尔值。

示例

js
const request = new Request("/myEndpoint", {
  method: "POST",
  body: "Hello world",
});

request.bodyUsed; // false

request.text().then(function (bodyAsText) {
  console.log(request.bodyUsed); // true
});

规范

规范
Fetch
# ref-for-dom-body-bodyused①

浏览器兼容性

参见