Skip to content

Commit

Permalink
docs(request): add blob() and formData() (#370)
Browse files Browse the repository at this point in the history
In sync with honojs/hono#2841
  • Loading branch information
fzn0x authored May 28, 2024
1 parent 50a0680 commit e6d1572
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions api/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const body = await c.req.parseBody({ dot: true })

## json()

Parse Request body of type `application/json`
Parses the request body of type `application/json`

```ts
app.post('/entry', async (c) => {
Expand All @@ -139,7 +139,7 @@ app.post('/entry', async (c) => {

## text()

Parse Request body of type `text/plain`
Parses the request body of type `text/plain`

```ts
app.post('/entry', async (c) => {
Expand All @@ -150,7 +150,7 @@ app.post('/entry', async (c) => {

## arrayBuffer()

Parse Request body as an `ArrayBuffer`
Parses the request body as an `ArrayBuffer`

```ts
app.post('/entry', async (c) => {
Expand All @@ -159,6 +159,28 @@ app.post('/entry', async (c) => {
})
```

## blob()

Parses the request body as a `Blob`.

```ts
app.post('/entry', async (c) => {
const body = await c.req.blob()
...
})
```

## formData()

Parses the request body as a `FormData`.

```ts
app.post('/entry', async (c) => {
const body = await c.req.formData()
...
})
```

## valid()

Get the validated data.
Expand Down

0 comments on commit e6d1572

Please sign in to comment.