Sends Content-Type: json when there is no payload on Nodejs
See original GitHub issueSummary
axios sends content-type: application/json
when sending data as params
(query string) and when no data at all for other http methods like DELETE
All api calls were of the form
axios({
method: "delete"..
}
The fix was to manually set headers["content-type"]=""
for such requests.
Context
This happens in node only and works fine in browser.
- axios version: v0.18.0
- Environment: node v8.10.0, windows 10
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
send Content-Type: application/json post with node.js
When sending JSON you just have to put it in body of the option. ... body: JSON.stringify(payload), headers: { "Content-Type": ...
Read more >Anatomy of an HTTP Transaction - Node.js
To do this, there's a method called [ writeHead ][], which writes the status code and the headers to the stream. response.writeHead(200, {...
Read more >Node-Red HTTP Request Node for Beginners
Common examples are setting the payload type when sending JSON data in post messages. You can use a function node or change node...
Read more >Reply - Fastify
serialize(payload) - Serializes the specified payload using the default JSON serializer or using the custom serializer (if one is set) and returns the ......
Read more >How do I send a POST request using JavaScript? - ReqBin
To send HTTP POST and GET requests in Node.js, use the built-in "http" module. In order to send the HTTP POST request using...
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
Closed due to too old. If you still have this problem, feel free to open a new one with detailed information. Thanks.
If you look at the
_header
property ofClientRequest
you could see thatContent-Type: application/json
is set.I am using the default one. Searching for the keyword in my entire project brings up only 3 occurrences:
Axios: 0.18.0 Node: 8.10 All fine in browser
Hope it helps 😃