profile
viewpoint

Ask questionsCannot get params from context

It seems that get method does not handle the parameter from the url if I write that route router.get('/book/:id', (context) => { // route action }) nothing is happening. I removed the '/:id' part of the string and that seems to be the issue here ... but how to indicate parameters if not that way ?

oakserver/oak

Answer questions kitsonk

Btw, would you know how to handle query param with oak though

ctx.request.url.searchParams.get("id");

I can see that is getting a bit cumbersome though, and some users would expect to be able to have the params and these "merged". I want to avoid creating aliases and the like, but I think a helper function that would return the searchParams as a single object optionally merged with the parsed out params would be a good idea... something that would work like this:

const query = queryParams(ctx, { mergeParams: true });
useful!

Related questions

No questions were found.
Github User Rank List