Axios vs jQuery post CORS issue
See original GitHub issueWhen doing a CORS post request, jQuery succeeds but Axios gets a CORS error in the console.
This gets a CORS error
Axios.post(endpoint, { email_address : emailAddress})
.then(function (response) {
isSentSuccessful = true;
})
.catch(function (response) {
errorAnimation();
});
But this works
jQuery.post(endpoint, { email_address : emailAddress },
function(resp){
isSentSuccessful = true;
})
.fail(function(resp){
errorAnimation();
});
Am I missing something with Axios? My server is already configured for CORS requests.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:19
- Comments:48 (4 by maintainers)
Top Results From Across the Web
jQuery ajax working but axios giving CORS error
In your jQuery, you are manually encoding the data as JSON and failing to set the correct Content-Type header. As a result you...
Read more >Axios vs. fetch(): Which is best for making HTTP requests?
Axios is not always an ideal solution; depending on your needs, there are sometimes better options for making HTTP requests.
Read more >ReactJS CORS Options - GeeksforGeeks
In axios: Axios always use base URL to start the request and the browser confirms that in the beginning HTTP OPTIONS requests by...
Read more >[Solved]-React CORS issue with fetch for POST request-Reactjs
Coding example for the question React CORS issue with fetch for POST ... Getting Bad request for POST request using Axios and CORS...
Read more >Fixing Common Problems with CORS and JavaScript
Many websites have JavaScript functions that make network requests to a server, such as a REST API. The web pages and APIs are...
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
Another way to deal with this, especially if it worked in jQuery
From Homyk comment on Dec 9, 2015, was able to come up with this and it worked.
I was setting up a little API to learn Grails. Doing a POST request, only by changing from jQuery to Axios, I went from getting this:
to this: