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

Unsupported content-type: application/json;charset=utf-8 with DELETE method? #47

Open
youngerheart opened this issue Jul 20, 2016 · 1 comment

Comments

@youngerheart
Copy link

Error: Unsupported content-type: application/json;charset=utf-8
      at module.exports (/Users/younger/Develop/grail/node_modules/co-body/lib/any.js:47:13)
      at _callee$ (/Users/younger/Develop/grail/node_modules/clannad/dist/app.js:63:41)
      at tryCatch (/Users/younger/Develop/grail/node_modules/regenerator-runtime/runtime.js:62:40)
      at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/younger/Develop/grail/node_modules/regenerator-runtime/runtime.js:336:22)
      at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Users/younger/Develop/grail/node_modules/regenerator-runtime/runtime.js:95:21)
      at step (/Users/younger/Develop/grail/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
      at /Users/younger/Develop/grail/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
      at new Promise (/Users/younger/Develop/grail/node_modules/core-js/library/modules/es6.promise.js:193:7)
      at /Users/younger/Develop/grail/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
      at /Users/younger/Develop/grail/node_modules/clannad/dist/app.js:126:16
      at dispatch (/Users/younger/Develop/grail/node_modules/koa-compose/index.js:43:32)
      at /Users/younger/Develop/grail/node_modules/koa-compose/index.js:36:12
      at Server.<anonymous> (/Users/younger/Develop/grail/node_modules/clannad/node_modules/koa/lib/application.js:135:7)
      at emitTwo (events.js:100:13)
      at Server.emit (events.js:185:7)
      at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:537:12)
      at HTTPParser.parserOnHeadersComplete (_http_common.js:89:23)
@youngerheart
Copy link
Author

youngerheart commented Aug 14, 2016

parse() is not useful and show error like I say, so I have to use like this

let type = ctx.headers['content-type'];
if (type.indexOf('application/json') > -1)
  ctx.req.body = await parse.json(ctx) || {};
else if (type.indexOf('application/x-www-from-urlencoded') > -1)
  ctx.req.body = await parse.form(ctx) || {};
else ctx.req.body = await parse(ctx) || {};

but document say parse() is either, am I wrong in usage?

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

1 participant