docs(example): replace useQuery to getQuery (#8047)

This commit is contained in:
Cupid Valentine 2022-10-08 17:32:20 +08:00 committed by GitHub
parent 45fd722dc1
commit 186a626e38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -158,7 +158,7 @@ Sample query `/api/query?param1=a&param2=b`
```ts [server/api/query.get.ts]
export default defineEventHandler((event) => {
const query = useQuery(event)
const query = getQuery(event)
return { a: query.param1, b: query.param2 }
})
```

View File

@ -1,7 +1,7 @@
import { useQuery, defineMiddleware } from 'h3'
import { getQuery, defineMiddleware } from 'h3'
export default defineMiddleware((req, res, next) => {
if ('api' in useQuery(req)) {
if ('api' in getQuery(req)) {
throw new Error('Server middleware error')
}
next()

View File

@ -1,4 +1,4 @@
export default defineEventHandler(event => ({
path: '/api/' + event.context.params.hello,
query: useQuery(event)
query: getQuery(event)
}))

View File

@ -7,7 +7,7 @@ export default defineLazyHandler(async () => {
)
return (event) => {
const { a = 0, b = 0 } = useQuery(event)
const { a = 0, b = 0 } = getQuery(event)
return { sum: sum(a, b) }
}
})