Karl Morrison Karl Morrison - 28 days ago 4x
Node.js Question

Koa-router not nesting

const router2 = new KoaRouter();
router2.get(`/test`, async function(ctx, next) {
ctx.body = 'api test';

const router = new KoaRouter();
router.get(`/1`, router2.routes(), router2.allowedMethods());
router.get(`/test`, async function(ctx, next) {
ctx.body = 'test';
does not work

I can't see the problem?


When you are using nested routes you need to use router.use instead of router.get.