Answer the question
In order to leave comments, you need to log in
What is the correct way to use koa-route for koa 2.x?
I'm trying to do it like this:
const Koa = require('koa'),
router = require('koa-router')(),
app = new Koa();
router.get('/hello', async (ctx, next) => {
ctx.body = 'it is working!';
});
Answer the question
In order to leave comments, you need to log in
the very first example from the official documentation
var app = require('koa')();
var router = require('koa-router')();
router.get('/', function (ctx, next) {...});
app
.use(router.routes())
.use(router.allowedMethods());
npm install [email protected]
I decided: there was a jamb in the etc/lightdm/lightdm.conf file (it was my own fault), I corrected it,
everything worked.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question