1

I am newbie in koa, and I am using koa-router. For me, the code is like:

this.router.get('/user/test',function(){
            debugger;
        })

then I visit localhost:3000/user/test?p=1&q=2, I just find that there seems no method for me to get the value of p and q. So how can I quickly get the value?

CoolGuy
  • 357
  • 2
  • 16

1 Answers1

3
var route = require('koa-route');
var koa = require('koa');
var app = koa();

// /user/test/?a=1&b=2 -> will console log your values
app.use(route.get('/user/test', function* () {
  console.log(this.query.a)
  console.log(this.query.b)
}));
Rotem Tamir
  • 1,397
  • 2
  • 11
  • 26