HTTPRequest.asFetchRequest() 方法
🌐 HTTPRequest.asFetchRequest() method
将请求转换为 Fetch API 的 Request 实例。
🌐 Converts the request to a Fetch API Request instance.
语法
🌐 Signature
class HTTPRequest {
asFetchRequest(): Promise<Request>;
}
返回:
Promise<Request>
一个返回 Fetch API 请求对象的 Promise。
🌐 A promise which resolves to a Fetch API Request object.
附注
🌐 Remarks
头部会被复制到新的请求实例中。请求的 URL 和方法会被保留。当请求有 post 数据时,body 会由 HTTPRequest.fetchPostData() 构建,否则请求会在没有 body 的情况下创建。对于 GET 和 HEAD 请求,body 总是会被省略,这是 Fetch API 的要求。
🌐 Headers are copied to the new Request instance. The request URL and method are preserved. The body is built from HTTPRequest.fetchPostData() when the request has post data, otherwise the Request is created without a body. For GET and HEAD requests the body is always omitted, as required by the Fetch API.