Get a Parameter Value in Oak
so if I set up a router like this then how do I get the value of the id parameter? I have tried ctx.id and it did not accept it
1 Reply
To get the value of the
id
parameter in Oak, you can use the getQuery
helper function from Oak's helpers
module. Here's how you can do it:
In this code, getQuery
is used to extract the parameters from the context. The mergeParams
option is set to true
to merge the named route parameters and the query string parameters into a single object. The id
parameter is then destructured from this object.