Closed hwoarangzk closed 9 years ago
module.exports = (next) ->
cosnole.log(this)
body = yield parser.json(this)
I think there's a icon request.
Maybe you should use https://github.com/koajs/bodyparser
is the data valid json data
?
@coderhaoxin I think is should be the valid json data
because I did nothing on the request, I just used the co-body
middleware.
@fengmk2 I'll try the bodyparser
you mentioned. Maybe the error has sth to do with the favicon request
. Is there anyway to avoid the favicon request
?
oh, just like @fengmk2 said, you need https://github.com/koajs/bodyparser
you should not parser.json(this)
for all the requests.
the error is from
JSON.parse(empty buffer)
@coderhaoxin So you mean that co-body
won't filter out the empty buffer request while koa-bodyparser
will?
@hwoarangzk If you use parser.json directly, you need to check content-type first.
Thank you all :) I know how to modify my code.
index.coffee:
and bodyParser.coffee:
Everytime when I refresh my page, it always reported:
Is there anything I've done wrong? Thanks