docs: fix types in 'server utilities' example (#22978)

This commit is contained in:
OrlS15 2023-09-04 10:22:52 +02:00 committed by GitHub
parent cdf9b5547e
commit 3c1d027977
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,10 +111,12 @@ For example, you can define a custom handler utility that wraps the original han
**Example:** **Example:**
```ts [server/utils/handler.ts] ```ts [server/utils/handler.ts]
import type { EventHandler } from 'h3' import type { EventHandler, EventHandlerRequest } from 'h3'
export const defineWrappedResponseHandler = (handler: EventHandler) => export const defineWrappedResponseHandler = <T extends EventHandlerRequest, D> (
defineEventHandler(async (event) => { handler: EventHandler<T, D>
): EventHandler<T, D> =>
defineEventHandler<T>(async event => {
try { try {
// do something before the route handler // do something before the route handler
const response = await handler(event) const response = await handler(event)