Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ihellodays opened this issue Aug 10, 2017 · 1 comment
Open

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

ihellodays opened this issue Aug 10, 2017 · 1 comment

Comments

@ihellodays
Copy link

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

@JacksonTian
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants