co-wechat icon indicating copy to clipboard operation
co-wechat copied to clipboard

koa2.x ctx.request.body === 'string' 而是object

Open ihellodays opened this issue 8 years ago • 1 comments

if (ctx.request.body && typeof ctx.request.body === 'string') { xml = ctx.request.body; } else { // 取原始数据 xml = await getRawBody(ctx.req, { length: ctx.request.length, limit: '1mb', encoding: ctx.request.charset || 'utf-8' }); }

在koa2.0下用的时候

ctx.request.body === 'string'

这个不是string 而是 object

ihellodays avatar Aug 10 '17 02:08 ihellodays

当 是 text/xml 提交的时候,直接解析成了 Object ?

JacksonTian avatar Aug 11 '17 01:08 JacksonTian