1.0.1 • Published 4 years ago

@seregpie/koa-body v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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);