请求:bytes() 方法
注意:此功能在 Web Workers 中可用。
bytes() 方法是 Request 接口的一部分,它读取请求体并返回一个 Promise,该 Promise 解析为一个 Uint8Array。
语法
js
bytes()
参数
无。
返回值
一个 Promise,它解析为一个 Uint8Array。
示例
js
const myArray = new Uint8Array(10);
const request = new Request("/myEndpoint", {
method: "POST",
body: myArray,
});
request.bytes().then((buffer) => {
// do something with the buffer sent in the request
});
规范
| 规范 |
|---|
| Fetch # dom-body-bytes |
浏览器兼容性
加载中…