Skip to content

Commit

Permalink
Update 3.routing.md
Browse files Browse the repository at this point in the history
Replace getRouteParam with getRouterParam
  • Loading branch information
tlebeitsuk committed Jan 19, 2024
1 parent 0551d96 commit 4e1e5ac
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/content/1.guide/3.routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ You do not need to import `defineEventHandler` as it is automatically imported t

#### Single param

To define a route with params, use the `[<param>]` syntax where `<param>` is the name of the param. The param will be available in the `event.context.params` object or using the `getRouteParam` utility from [unjs/h3](https://h3.unjs.io).
To define a route with params, use the `[<param>]` syntax where `<param>` is the name of the param. The param will be available in the `event.context.params` object or using the `getRouterParam` utility from [unjs/h3](https://h3.unjs.io).

```ts [/hello/[name].ts]
export default defineEventHandler(event => {
const name = getRouteParam(event, 'name')
const name = getRouterParam(event, 'name')

return `Hello ${name}!`
})
Expand All @@ -73,8 +73,8 @@ You can define multiple params in a route using `[<param1>]/[<param2>]` syntax w

```ts [/hello/[name]/[age].ts]
export default defineEventHandler(event => {
const name = getRouteParam(event, 'name')
const age = getRouteParam(event, 'age')
const name = getRouterParam(event, 'name')
const age = getRouterParam(event, 'age')

return `Hello ${name}! You are ${age} years old.`
})
Expand All @@ -86,7 +86,7 @@ You can capture all the remaining parts of a URL using `[...<param>]` syntax. Th

```ts [/hello/[...name].ts]
export default defineEventHandler(event => {
const name = getRouteParam(event, 'name')
const name = getRouterParam(event, 'name')

return `Hello ${name}!`
})
Expand All @@ -106,7 +106,7 @@ You can append the HTTP method to the filename to force the route to be matched
```js [GET]
// routes/users/[id].get.ts
export default defineEventHandler(async (event) => {
const id = getRouteParam(event, 'id')
const id = getRouterParam(event, 'id')

// Do something with id

Expand All @@ -126,7 +126,7 @@ export default defineEventHandler(async event => {
```
::

Check out [h3 JSDocs](https://www.jsdocs.io/package/h3) for all available utilities like `getRouteParam` or `readBody`.
Check out [h3 JSDocs](https://www.jsdocs.io/package/h3) for all available utilities like `getRouterParam` or `readBody`.

### Catch all route

Expand Down

0 comments on commit 4e1e5ac

Please sign in to comment.