Node.js
Koa Framework v2
Buscar..
Hola mundo ejemplo
const Koa = require('koa')
const app = new Koa()
app.use(async ctx => {
ctx.body = 'Hello World'
})
app.listen(8080)
Manejo de errores utilizando middleware.
app.use(async (ctx, next) => {
try {
await next() // attempt to invoke the next middleware downstream
} catch (err) {
handleError(err, ctx) // define your own error handling function
}
})
Modified text is an extract of the original Stack Overflow Documentation
Licenciado bajo CC BY-SA 3.0
No afiliado a Stack Overflow