码迷,mamicode.com
首页 > Web开发 > 详细

基于 Koa平台Node.js开发的KoaHub.js的输出json到页面代码

时间:2016-09-28 13:10:47      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

koahub-body-res

koahub body res

Format koa‘s respond json.

$ npm install koahub-body-res
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

技术分享

基于 Koa平台Node.js开发的KoaHub.js的输出json到页面代码

标签:

原文地址:http://www.cnblogs.com/jycxqe/p/5915821.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!