N
Nuxt2mo ago
Gillette

Get route query params in the seriver side returns undefined

Hello! I have an endpoint in my backend that accepts GET requests with query parameters, but in side the defineEventHandler I'm not able to get these parameters. For some reason, the documentation on the server side for handling parameters is very little. Code Snippet: export default defineEventHandler(async (event) => { // Read body params const routeParams = getRouterParams(event) console.log(routeParams, event) ... Console log content: {} H3Event { ... (the event passes the char limit of the discord post) The content of the params object is always an empty object, despite the parameters being sent, the url in the H3Event is "/api/categories?q&page=1&limit=10&sort=id&order=asc" which is correct. What could I be doing wrong?
No description
1 Reply
Gillette
Gillette2mo ago
It must be from spending too much time on the PC today working on this project, I totally missed the correct method in the docs. I just have to use: getQuery(event)