Skip to content

Commit

Permalink
fixed a few typos
Browse files Browse the repository at this point in the history
- Fixed a code typo that said `.get` instead of `.post`
- Updated wording about "warning" in anticipation of honojs/hono#3707
- Reworded code block descriptors
  • Loading branch information
Soviut authored Nov 30, 2024
1 parent a471fa1 commit d635a2f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/guides/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ Validation targets include `json`, `query`, `header`, `param` and `cookie` in ad
::: warning
When you validate `json`, the request _must_ contain a `Content-Type: application/json` header
otherwise the request body will not be parsed and you will invalid JSON errors.
otherwise the request body will not be parsed and you will receive a warning.
It is important to set the `content-type` header when testing using
[`app.request()`](../api/request.md).
If you had an app set up like this.
Given an application like this.
```ts
const app = new Hono()
app.get(
app.post(
'/testing',
validator('json', (value, c) => {
// pass-through validator
Expand All @@ -73,7 +73,9 @@ app.get(
}
)
```
And your tests were set up like this.
Your tests can be written like this.
```ts
// ❌ this will not work
const res = await app.request('/testing', {
Expand All @@ -82,9 +84,7 @@ const res = await app.request('/testing', {
})
const data = await res.json()
console.log(data) // undefined
```

```ts
// ✅ this will work
const res = await app.request('/testing', {
method: 'POST',
Expand Down

0 comments on commit d635a2f

Please sign in to comment.