Skip to content

Commit

Permalink
fix: type for get router parameter utils
Browse files Browse the repository at this point in the history
  • Loading branch information
cerinoligutom committed Jun 7, 2023
1 parent 3e5f427 commit aa4569a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ export function getQuery(event: H3Event) {
return _getQuery(event.node.req.url || "");
}

export function getRouterParams(event: H3Event): H3Event["context"] {
export function getRouterParams(
event: H3Event
): NonNullable<H3Event["context"]["params"]> {
// Fallback object needs to be returned in case router is not used (#149)
return event.context.params || {};
}

export function getRouterParam(
event: H3Event,
name: string
): H3Event["context"][string] {
): string | undefined {
const params = getRouterParams(event);

return params[name];
Expand Down

0 comments on commit aa4569a

Please sign in to comment.