Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

koa-body-parser

thomseddon7.4kMIT1.1.2

Parse request body into ctx.request.body

koa

readme

koa-body-parser Build Status

Parse the request body in koa like ya' used to in express

Installation

npm install koa-body-parser

Options

  • empty whether to throw a 415 if the client has indicated there is a body but it cannot be parsed (default: true)
  • length length limit of the stream to pass to raw-body (default: content-length)
  • limit byte limit of the body to pass to raw-body, throws 413 if body is larger
  • encoding requested encoding (default: utf8)

Example

var bodyParser = require('koa-body-parser');
var koa = require('koa');

var app = koa();

app.use(bodyParser());

app.use(function *() {
  this.body = this.request.body; // Echo request back
  this.status = 200;
});

app.listen(3000);

License

MIT

changelog

1.1.0

  • Silently skip requests to parse a body that has already been parsed
  • Accept and pass through all co-body params

1.0.0

Changed name from koa-request-body to koa-body-parser, major bump in case anyone was still depending on the previous name

0.0.1

Inital release