From aa4569afe4321fa46ab1a6de22d0fef354f9eb40 Mon Sep 17 00:00:00 2001 From: Cerino Ligutom III Date: Wed, 7 Jun 2023 11:54:18 +0800 Subject: [PATCH] fix: type for get router parameter utils --- src/utils/request.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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];