@seregpie/koa-body
v1.0.1
Published
A simple body fetcher.
Downloads
1
Readme
KoaBody
A simple body fetcher.
dependencies
setup
npm i @seregpie/koa-body
usage
let Koa = require('koa');
let KoaBody = require('@seregpie/koa-body');
let app = new Koa();
app.use(async ctx => {
ctx.body = await KoaBody.json(ctx);
});
Fetch the body as application/json
.
let body = await KoaBody.json(ctx);
Set explicit limit.
let body = await KoaBody.json(ctx, {limit: '16mb'});
Fetch the body as text/plain
.
let body = await KoaBody.text(ctx);
Fetch the body as a Buffer
.
let body = await KoaBody(ctx);