Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zh-CN:translate request-blob #6892

Merged
merged 5 commits into from
Jul 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions files/zh-cn/web/api/request/blob/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: Request.blob()
slug: Web/API/Request/blob
page-type: web-api-instance-method
tags:
- API
- Blob
- Fetch
- Method
- Reference
- Request
translation_of: Web/API/Request/blob
---
{{APIRef("Fetch")}}

{{domxref("Request")}} 接口的 **`blob()`** 方法读取请求体并将其作为 promise 返回,该 promise 将兑现一个 {{domxref("Blob")}}。

## 语法

```js
blob()
```

### 参数

无。

### 返回值

一个 promise,会兑现一个 {{domxref("Blob")}}。

## 示例

```js
const obj = {hello: 'world'};
const myBlob = new Blob([JSON.stringify(obj, null, 2)], {type : 'application/json'});

const request = new Request('/myEndpoint', {
method: 'POST',
body: myBlob
});

request.blob().then(function(myBlob) {
// do something with the blob sent in the request
});
```

## 规范

{{Specifications}}

## 浏览器兼容性

{{Compat}}

## 参见

- {{domxref("Response.blob()")}}