Content-Type not working at GET requests
See original GitHub issueI’m trying to make a GET request with a ‘Content-Type’ like ‘application/vnd.api+json’ and its not working, the content-type is not being changed. 😢
const api = create({
baseURL: 'http://localhost:3000',
headers: {
'Content-Type': 'application/vnd.api+json',
'Accept': 'v1'
}
})
api
.get('users/token_exists', { confirmation_token: token })
.then((response) => {
console.log(response.status)
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Do I need a content-type header for HTTP GET requests?
GET requests can have "Accept" headers, which say which types of content the client understands. The server can ...
Read more >Content-Type - HTTP - MDN Web Docs - Mozilla
In responses, a Content-Type header provides the client with the actual content type of the returned content. This header's value may be ignored...
Read more >HTTP request with Content-type not supported
Hello,. I created a flow in Power Automate, and when I run a specific HTTPS request (GET method) with the HTTP module :....
Read more >How do I set the content type for a Curl request? - ReqBin
Setting the Content-Type with Curl Request. To send the Content-Type header using Curl, you need to use the -H command-line option.
Read more >Quickstart — Requests 2.28.1 documentation
Requests ' simple API means that all forms of HTTP request are as obvious. ... Please note that the above code will NOT...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
@fabiodiniz This isn’t actually a bug in either of the libraries though. The
Content-Type
header refers to the type of data you are sending to the server and as such there is no reason to send it if there’s no body to the request. My guess is that you would want to use theAccept
header which specifies how you want your response formatted.This is what I think you’re actually looking for:
@guziyu001
You need to pass an empty
data
object, so theContent-Type
will be sent . Idk why, but Axios don’t send custom headers inGET
requests when there is nodata
object.Your code would look like this: