Koa router: how to get query string parameters?

I am using koa-router.

How do I get the query string parameters of a query?

This is the best I managed to write:

import koaRouter from 'koa-router'; const router = koaRouter({ prefix: '/courses' }); router.get('/', async (ctx) => { console.log(ctx.qs["lecturer"]); }); 

but qs is undefined

Any help would be greatly appreciated!

+5
source share
1 answer

According to the docs, there should be ctx.request.query , which is the elements of a query string, presented as an object.

+11
source

Source: https://habr.com/ru/post/1266419/


All Articles