diff --git a/src/utils/request.ts b/src/utils/request.ts index dfa93047..4e81b5e1 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -7,7 +7,9 @@ export function getQuery(event: H3Event) { return _getQuery(event.node.req.url || ""); } -export function getRouterParams(event: H3Event): H3Event["context"] { +export function getRouterParams( + event: H3Event +): NonNullable { // Fallback object needs to be returned in case router is not used (#149) return event.context.params || {}; } @@ -15,7 +17,7 @@ export function getRouterParams(event: H3Event): H3Event["context"] { export function getRouterParam( event: H3Event, name: string -): H3Event["context"][string] { +): string | undefined { const params = getRouterParams(event); return params[name];