Home > php教程 > php手册 > KoaHub.js developed based on Node.js outputs json to the page

KoaHub.js developed based on Node.js outputs json to the page

WBOY
Release: 2016-09-29 09:18:55
Original
986 people have browsed it

基于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

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template