Closed sunyongjian closed 6 years ago
my code
const bodyparser = require('koa-bodyparser'); const json = require('koa-json'); app.use(bodyparser({ enableTypes:['json', 'form', 'text'] })); app.use(json());
//router router.post('/abc', async (ctx) => { console.log(ctx.request.body, 'body'); ctx.body = ctx.request.body; });
when i request '/abc':
content-type is application/x-www-form-urlencoded
request-body data[template_col][p_price_value][taxes_by_distance_serial_interval][intervals][0][begin]: 0
then ctx.request.body is:
{ "data": { "template_col": { "p_price_value": { "taxes_by_distance_serial_interval": { "intervals": [ { "[begin]": "1" } ] } } } } }
why not
"intervals": [ { "begin": "1" } ]
But expressjs/bodyparser is okay...
resolve:
app.use(bodyparser({ enableTypes:['json', 'form', 'text'], queryString: { depth: Infinity } }));
my code
when i request '/abc':
content-type is application/x-www-form-urlencoded
request-body data[template_col][p_price_value][taxes_by_distance_serial_interval][intervals][0][begin]: 0
then ctx.request.body is:
why not
But expressjs/bodyparser is okay...