Axios not returning response for POST on 500 error
See original GitHub issueI setup a basic demo, where I create a POST request and server returns 500 error. With postman I get response, but axios doesn’t return response. https://jsfiddle.net/8r3dh6hw/61/
Response from Postman: 500 Internal Server Error
Issue Analytics
- State:
- Created 6 years ago
- Reactions:13
- Comments:11
Top Results From Across the Web
Axios POST request fails with error status code 500
Most of the time it happens because of using wrong content type header. Open postman and see "Body" ...
Read more >500 (Internal Server Error) when POSTing to controller with ...
Hi! I'm making an Instagram 'clone' and want to add comments using Axios. I have a resourceful controller setup and a Vue instance...
Read more >trying to post json with axios? 500 (Internal Server Error)?
I'm trying to convert the plain text that's entered from review with axios. However I get an error in the console log saying:...
Read more >request failed with status code 500 axios post - You.com
While it seems like that there are quite a few reasons you might get a 500 response from an Axios call, my case...
Read more >Axios HTTP error handling in Express.js
A status code 5xx indicates an error at the other service or in the network between our and the other service. Some of...
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 Free
Top 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
@themre For me, what worked was to implement
validateStatus
and returntrue
for the status codes I wanted to handle in thethen
callback.@themre In your jsfiddle, if you look in the browser dev tools, you’ll notice that the call to
httpstat.us/500
errors during theOPTIONS
pre-flight request (an automated network call in modern browsers when using CORS). When making a cross-domain request, if the server isn’t correctly configured for CORS, axios returns an error withouterror.response
populated. This is because the XHR request fails at the browser level (during theOPTIONS
call), which is technically a network error. For network errors, axios does not provide a response because one is not provided by the browser. If one debugs the network error returned to axios from an invalidOPTIONS
call, one will notice that there is no way to know the status.