Closed imkimchi closed 7 years ago
I just figured out It stored in ctx.request.fields
not ctx.request.fields
:(
It needs to be fixed as koa-bodyparser
store everything in body to ctx.request.body
and people could get confused easily
Oooooh damn, i forgot that. We had issues with that before. Before few versions it was body. i believe. But was changed if i remember correctly. However, it can be changed with options, so not so big problem :) Maybe some notes need, but i always think that this module si mostly the best documented of my all. Don't know.
Try options.fields
to set it to string options.fields: 'body'
:+1:
edit: .request.fields
is just preference. It make a lot of sense, exactly in json context, because any sane parser should handle JSON by default. So we do that: response comes -> if JSON -> parse it -> push it as fields
. Probably, don't know.
edit2: It writes to ctx.request.body
only when buffer and text.
Anyway, very thanks that we clarified all that mess :)
after multipart/form-data parsing works fine, there are some issues with other routers that don't use multipart/form-data, but json request. It sends POST request from client using
axios
. and It worked fine withkoa-bodyparser
but doesn't work withkoa-better-body
.I've tested some codes and I figured that It parse the POST request but not body. I read that
koa-better-body
will parse no body when the header ismultipart/form-data
but the POST request is just a json request.request info
client code
router
app.js