I developed a couple of APIs for a Deno Proof of Concept.
This is the route implementation:
const router = new Router()
router.get('/posts', getPosts)
.get('/posts/:id', getPostsById)
In the second route, I successfully retrieved the path parameter in the controller function getPostsById using the variable: params. Here is the corresponding controller code:
export const getPostsById = (
{ params, response }: { params:any, response: any }) => {
console.log(params, '||| params')}
Now I am wondering how to retrieve query parameters in a similar manner (e.g., /posts/2222?userId=3)
My routing framework is Oak. Despite trying different keywords like query and search from the Oak library, I have not been able to succeed in fetching the query parameter.
I also attempted to use getQuery method as suggested in the Oak documentation, but I faced issues with importing it into my project.