Reputation: 902
I tried to import the koa-router into my nodejs app like this:
but when checking the code completion, there is no get
method to be found. Or any other method.
I installed it using npm install koa-router
but apparently something is not working.
Can someone help me?
Upvotes: 0
Views: 223
Reputation: 2771
koa-router
is now @koa/router
. In the documentation you should find this:
This module is forked from the original koa-router due to its lack of activity.
So your code should look like this:
const Koa = require('koa');
const Router = require('@koa/router');
const app = new Koa();
const router = new Router();
router.get('/', (ctx, next) => {
// ctx.router available
});
This way I guess, your code completion should work. Can you confirm this?
Upvotes: 1