Closed 75lb closed 7 years ago
If nothing was parsed why does ctx.request.body have a value (empty object)?
ctx.request.body
In both these cases ctx.request.body equals {}: a) The request body was empty b) The request body was '{}'
{}
How do I distinguish whether the request body was empty or '{}'? What's the recommended method to test whether the request body is empty?
'{}'
this is by design, so you don't need to check body exists every time.
you can use ctx.request.rawBody to get the original request body string. https://github.com/koajs/bodyparser#raw-body
ctx.request.rawBody
If nothing was parsed why does
ctx.request.body
have a value (empty object)?In both these cases
ctx.request.body
equals{}
: a) The request body was empty b) The request body was '{}'How do I distinguish whether the request body was empty or
'{}'
? What's the recommended method to test whether the request body is empty?