Request:body 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Request 接口的只读 body 属性包含一个 ReadableStream,其中包含已添加到请求中的主体内容。请注意,使用 GETHEAD 方法的请求不能有主体,这些情况下返回 null

示例

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

request.body; // ReadableStream

规范

Specification
Fetch
# ref-for-dom-body-body①

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
body

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

参见