mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35:13 +00:00
docs(example): replace useQuery to getQuery (#8047)
This commit is contained in:
parent
45fd722dc1
commit
186a626e38
@ -158,7 +158,7 @@ Sample query `/api/query?param1=a¶m2=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 }
|
||||
})
|
||||
```
|
||||
|
@ -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()
|
||||
|
@ -1,4 +1,4 @@
|
||||
export default defineEventHandler(event => ({
|
||||
path: '/api/' + event.context.params.hello,
|
||||
query: useQuery(event)
|
||||
query: getQuery(event)
|
||||
}))
|
||||
|
@ -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) }
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user