Setting header: 'Content-Type': 'application/json' is not working
See original GitHub issueHi. I’m passing a custom header like this
axios.get('my/url', {
headers: {
'Content-Type': 'application/json'
}
})
But it doesn’t seem to work. Any ideas?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:71
- Comments:30 (1 by maintainers)
Top Results From Across the Web
PHP header('Content-Type: application/json'); is not working
For some reason, my response header always comes as Content-Type:text/html; charset=UTF-8. I want content type to be json (Content-Type: ...
Read more >Working with application/json content type in Deno - Medium
Set content -type header to application/json. Here is an example of sending JSON in a fetch Request: const body={ a: 'b', c: 10...
Read more >What is the Correct Content-Type for JSON? Request Header ...
This means when you're sending JSON to the server or receiving JSON from the server, you should always declare the Content-Type of the...
Read more >How do I set the content type for a Curl request? - ReqBin
If you don't set the correct Content-Type, your app may not work. For example, the target server can accept XML and JSON data...
Read more >The application/problem+json Content-Type - SymfonyCasts
Setting the Content-Type Header¶ ... When we try the tests, they still pass! And now the client knows a bit more about our...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, I can confirm. If there is no
data
passed it removes the Content-Type… I just addeddata: {}
to myGET
request, and it works fine. It’s really weird to pass data on get requests but I don’t mind 👍If a user of this package wants to set a
Content-Type
header without a body, shouldn’t they be able to do that? I don’t see the argument for limiting the use here by either forcing a dummy payload or preventing theContent-Type
header from being set. This choice should be up to the user unless there is a good reason to prevent it.