I'm using koa-router.
我正在使用koa-router。
How can I get the request's query string params?
如何获取请求的查询字符串参数?
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
但是qs是未定义的
Any help will be profoundly appreciated!
任何帮助将深表感谢!
1 个解决方案
#1
15
According to the docs there should be a ctx.request.query
that is the query string items represented as an object.
根据文档,应该有一个ctx.request.query,它是表示为对象的查询字符串项。
#1
15
According to the docs there should be a ctx.request.query
that is the query string items represented as an object.
根据文档,应该有一个ctx.request.query,它是表示为对象的查询字符串项。