koahub body res
Format koa‘s respond json.
Installation
$ npm install koahub-body-res
Use with koa
var app = require(‘koa‘)();
var koaRes = require(‘koahub-body-res‘);
app.use(koaRes());
this.data = ‘This is a body‘;
this.msg = ‘This is a msg‘;
output
this.body = {
code: 200,
data: ‘This is a body‘,
msg: ‘This is a msg‘
}
时间: 2024-10-01 06:16:47