首页 >php教程 >php手册 >基于Node.js开发的KoaHub.js的输出json到页面

基于Node.js开发的KoaHub.js的输出json到页面

WBOY
WBOY原创
2016-09-29 09:18:55998浏览

基于Node.js开发的KoaHub.js的输出json到页面
koahub-body-res

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';
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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn