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.

Seems that “Post JSON” don’t work. Because if body is string (and JSON is actually a string) polyfill sets header ‘content-type’ to ‘text/plain;charset=UTF-8’

But in docs:

fetch('/users', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Hubot',
    login: 'hubot',
  })
})

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mislavcommented, Oct 11, 2016

You seem to be sending a POST to another domain. Please familiarize yourself with CORS to learn what’s blocking you from changing the Content-Type of the request.

0reactions
shapkarincommented, Oct 13, 2016

@mislav sorry, that was about server configuration. Fetch is a great way to write XHR 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advantages of using application/json over text/plain? [closed]
JSon is basically a format of plain text. As such it can't be faster than the best plain text ...
Read more >
What is JSON text ? - GeeksforGeeks
JSON is just the plain text written as a javascript object. There exist several key-value pairs which represent some useful information. The ...
Read more >
Convert JSON to Plain Text - Online JSON Tools
Simple, free and easy to use online tool that converts JSON to plain text. No ads, popups or nonsense, just a JSON to...
Read more >
What is the Correct Content-Type for JSON? Request Header ...
JSON has to be correctly interpreted by the browser to be used appropriately. text/plain was typically used for JSON, but according to IANA, ......
Read more >
Content-Type is text/plain instead of application/json #4768
Describe the bug. The route api/v1/query_range returns a json body but the content-type header is set to test/plain. To Reproduce
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