5
我正在使用koa-router。Koa路由器:如何获取查询字符串参数?
我怎样才能得到请求的查询字符串参数?
这是我好不容易才写的最好的:
import koaRouter from 'koa-router';
const router = koaRouter({ prefix: '/courses' });
router.get('/', async (ctx) => {
console.log(ctx.qs["lecturer"]);
});
但qs
未定义
任何帮助将深刻地感谢!
ctx.request.query未定义,虽然ctx.request.url是'/ api/courses?lecturer = John_Smith' – Alon
@Alon你如何将路由器安装到应用程序上? – robertklep
我不知道发生了什么变化,但突然ctx.request.query正在工作 – Alon