I'm developing node server using koa.js
I have looked for some libraries for body parser.
And there are several kinds of koa body parser.
But I don't know what differences btw them including koa-body and koa-bodyparser.
Can you explain it?
Thank you in advance.
koa-body
now support koa version 2. The main difference now remains about file payload parsing. The koa-bodyparser
cannot parse files, i.e. multipart/form-data
.
Oh, I got it.
https://github.com/koajs/koa/wiki
koa-body supports koa v1, koa-bodyparser supports koa v2.
And former can parse file, but later can't.
Thanks.
Both are Koa body parser middleware. I recently faced an issue where I wanted to handle file upload and there comes the main difference.
Koa-body supports -- koa, urlencoded, multipart, json, body, parser, form and
koa-bodyparser supports -- json, urlencoded, koa, body.
So if you are looking for file uploading features , go ahead with koa-body or koa-better-body (which has more wider scopes)
Here is detailed reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With