docs: mention `readValidatedBody` and `getValidatedQuery` (#24990)

This commit is contained in:
Luke Nelson 2024-01-01 22:05:43 +00:00 committed by GitHub
parent 219d1cd219
commit 931f96cdce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -230,6 +230,10 @@ export default defineEventHandler(async (event) => {
})
```
::callout{icon="i-ph-lightbulb" color="green" to="https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web#runtime-type-safe-request-utils"}
Alternatively, use `readValidatedBody` with a schema validator such as Zod for runtime and type safety.
::
You can now universally call this API using:
```vue [app.vue]
@ -259,6 +263,10 @@ export default defineEventHandler((event) => {
})
```
::callout{icon="i-ph-lightbulb" color="green" to="https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web#runtime-type-safe-request-utils"}
Alternatively, use `getValidatedQuery` with a schema validator such as Zod for runtime and type safety.
::
### Error Handling
If no errors are thrown, a status code of `200 OK` will be returned.