Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
koa middleware demo
node v8.17.0
version:
2.0.0
endpoint
share
tweet
const Koa = require('koa'); const app = new Koa(); // 1 app.use(async (ctx, next) => { console.log('1'); await next(); console.log('1.1'); }); // 2 app.use(async (ctx, next) => { console.log('2'); await next(); console.log('2.1'); }); // 3 app.use(async (ctx, next) => { console.log('3'); await next(); console.log('3.1'); }) // response app.use(async ctx => { ctx.body = 'Hello World'; console.log('Hello World'); }); app.listen(3000);
Created from: https://koajs.com/
Loading…
no comments
sign in
to comment