axios.post sends a GET request
See original GitHub issueSummary
This code should send a POST request, but sends a GET request ! It happens only when my app is deployed on my production server. But the bug happens before reaching the back-end so I don’t understand what is happening and why it is related to the environment. No problem on my local machine.
axios.post('/api/admin/tags/', formData)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.log(error.response.data);
});
Context
- axios version: v0.17.1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:12
- Comments:9
Top Results From Across the Web
axios.post is sending a GET request - Stack Overflow
I found this issue happens when Axios receives a 301 (Moved Permanently), because it makes a redirect but also changes the method to...
Read more >How to make HTTP requests with Axios - LogRocket Blog
Making an HTTP request is as easy as passing a config object to the Axios function. You can make a POST request using...
Read more >Axios tutorial - GET/POST requests in JavaScript with Axios
Axios makes it easy to send asynchronous HTTP requests to REST endpoints and perform CRUD operations. It can be used in plain JavaScript...
Read more >Making HTTP requests with Axios - CircleCI
Axios works by making HTTP requests with NodeJS and XMLHttpRequests on the browser. If the request was successful, you will receive a response ......
Read more >How to Perform HTTP Requests with Axios – A Complete Guide
Axios is a promise-based HTTP client for Node.js and the browser. Sending asynchronous HTTP queries to REST endpoints and performing CRUD ...
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
OK just found the solution ! https://stackoverflow.com/questions/47208440/axios-xmlhttprequest-is-sending-get-instead-of-post-in-production-environment
this was caused the trailing slash at the end of the request URI, which was causing a 301 redirect. The POST request was not visible in the XHR tab of Chrome’s debug console.
Same here, some api routes need tail ‘/’, I just skipped it and it automatically does a GET request