1.0.6 • Published 6 years ago

koa-querybody v1.0.6

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

koa-querybody

koa-querybody is a koa middleware for merging content.request.query and content.request.body (if it exist)

Install

Install with npm

$ npm install koa-querybody

Hello world

npm install koa
npm install koa-body
npm install koa-querybody

index.js:

const Koa = require('koa');
const koaBody = require('koa-body');
const koaQuerybody = require('koa-querybody')

const app = new Koa();

app.use(koaBody());
app.use(koaQuerybody());

app.use(ctx => {
  console.log(ctx.params);
  console.log(ctx.request.params) // The same to call ctx.params
});

app.listen(3000);
$ node index.js
$ curl -i http://localhost:3000/users?age=20 -d "name=test"
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 29
Date: Wed, 03 May 2017 02:09:44 GMT
Connection: keep-alive

{"age":"20", "name":"test"}

License

The MIT License, 2018 Fred Shaw (@FredShawF)

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago