question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: unsupported BodyInit type when attempting to post data to endpoint accepting the "application/x-www-form-urlencoded" content-type

See original GitHub issue

After updating to the latest version of frisbee to make use of the new abort features, I’ve encountered errors with posting data in a url-encoded format. I’m downgrading for the time being as I have no issues with v2.0.6.

An example of the offending code is as follows:

api
      .post(constants.routes.authentication.post_login(), {
        body: qs.stringify(credentials),
        headers: {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        abortToken
      })

The end point accepts this format, and this format alone. One thing to note is this error is being thrown before the request to the server has been sent.

Version: 3.0.2 Stack Trace:

unsupported BodyInit type
- node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:279:24 in _initBody
- node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:398:19 in Request
- node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:486:32 in <unknown>
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:485:23 in fetch
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js:434:53 in abortableFetch
- node_modules/raven-js/src/raven.js:1474:21 in <unknown>
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/regenerator-runtime/runtime.js:271:30 in invoke
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:3:103 in asyncGeneratorStep
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:5:212 in _next
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:5:369 in <unknown>
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:5:108 in <unknown>
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/regenerator-runtime/runtime.js:45:44 in tryCatch
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/regenerator-runtime/runtime.js:271:30 in invoke
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:3:103 in asyncGeneratorStep
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:5:212 in _next
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:5:369 in <unknown>
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
* /Users/chrisevans/Documents/GitHub/busybees-up-toolkit/node_modules/frisbee/lib/index.js:5:108 in <unknown>
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in <unknown>
- ... 8 more stack frames from framework internals

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
niftylettucecommented, Nov 28, 2019

Released on npm as frisbee@3.1.1 🎉

0reactions
niftylettucecommented, Nov 28, 2019

This is actually resolved as of v3.1.2, not v3.1.1. See https://github.com/niftylettuce/frisbee/commit/45f46140f379dc2e2175d8c52afd60f7c24a2dfa.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: unsupported BodyInit type when attempting to post data ...
Error: unsupported BodyInit type when attempting to post data to endpoint accepting the "application/x-www-form-urlencoded" content-type #94.
Read more >
React Native fetch "unsupported BodyInit type" - Stack Overflow
Even I tried the same POST request for One-Signal REST API for creating notifications,the below worked for me fine. const bodyObj = {...
Read more >
How to set Form-data in Rest Message - ServiceNow
You can check the content type of each attachment in sys_attachment table. Specify that content type in the 'Content-Type" header and try. And...
Read more >
Issue with receiving HTTP with Content-Type:application/x ...
First service: It passes all the necessary data as the URL parameters. It has Content-Type : application/json and the empty body.
Read more >
POST request using fetch in Next.Js - Product
Today, I'm trying to send a POST request to a Freshdesk API but i'm ... and now I'm getting a new error saying...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found