在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:venables/koa-json-body开源软件地址:https://github.com/venables/koa-json-body开源编程语言:JavaScript 100.0%开源软件介绍:koa-json-bodyA single-purpose koa middleware to only parse JSON request bodies and nothing else. By default, this libarary parses all valid JSON bodies on If there is a JSON parsing error, or if the request is not of valid type, To ensure Installationyarn add koa-json-body or via npm: npm install koa-json-body --save Options
Additional options available via co-body. UsageOn a every route: const body = require('koa-json-body')
app.use(body({ limit: '10kb', fallback: true }))
app.use((ctx, next) => {
console.log(ctx.request.body)
}) On a per-route basis (this example uses koa-router): const body = require('koa-json-body')({ limit: '10kb' })
app.post('/users', body, (ctx, next) => {
console.log(ctx.request.body)
}) TestingTo test, simply run
Made for koa 2 and beyondFor koa 0.x and 1.x support, see the koa-1 branch. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论