koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 116 forks source link

Usage example for 3.x doesn't work? #41

Closed mhingston closed 8 years ago

mhingston commented 8 years ago

Hi,

The usage example for 3.x doesn't seem to work?

var bodyParser = require('koa-bodyparser');
var koa = require('koa');

var app = new koa();
app.use(bodyParser());

app.use(function(ctx, next) {
  // the parsed body will store in this.request.body
  // if nothing was parsed, body will be an empty object {}
  ctx.body = ctx.request.body;
});

app.listen(3000);

Once the app server is running if I send a POST request with some data I just get an empty object returned?

$ curl http://127.0.0.1:3000 -F foo="bar"
{}
dead-horse commented 8 years ago

this module don't handle multipart form, you can try https://github.com/cojs/busboy instead. :)

mhingston commented 8 years ago

Oh ok, thanks.