Replies: 3 comments 1 reply
-
I'm just learning too. Is it just |
Beta Was this translation helpful? Give feedback.
-
For anyone still finding an answer: |
Beta Was this translation helpful? Give feedback.
-
The requirement I had when I tried to use RouterContext was getting access to route parameters. Since I found a different way to get access to route parameters and the RouterContext API is quite uncomfortable to be honest I opted for not using RouterContext at all. This is what I ended up with. import { Context, helpers } from '@oak/oak';
function testHandler(ctx: Context) {
const params = helpers.getQuery(ctx, { mergeParams: true });
console.debug(params);
ctx.response.body = `Path parameter was '${params.myparam}'`;
} See the docs for more |
Beta Was this translation helpful? Give feedback.
-
Hello,
Consider the following code
When run with
deno run --allow-net test.ts
and accessed withcurl localhost:3000/test/asd
will respond withPath parameter was 'asd'
as expected.But when you type check that with
deno run --allow-net --check test.ts
or simply open it with vsode and the deno extension, it throws the following:error: TS2707 [ERROR]: Generic type 'RouterContext<R, P, S>' requires between 1 and 3 type arguments
.What would be the right type definition for
ctx
in thetestHandler
function to make Typescript happy?.Thanks.
Beta Was this translation helpful? Give feedback.
All reactions