登录
注册
node.js 学习社区
基于 Koa平台Node.js开发的KoaHub.js的输出json到页面代码

wemallshop

2016-09-28 11:57

koahub-body-reskoahub 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';

this.go = 'This is a go url';


output


this.body = {

code: 200,

data: 'This is a body',

msg: 'This is a msg'

}


this.body = {

code: 200,

data: 'This is a body',

msg: 'This is a msg',

go: 'This is a go url'

};


官网:http://js.koahub.com

回复 · 0

发表回复

你可以在回复中 @ 其他人