Repository navigation
How Handle CORS issue using axios in react #6786
Closed
samprasdsouza
started this conversation in
General
Replies: 1 comment
|
Hi How to Differentiate them is that You can distinguish a CORS/Network error from a Bad Request (4xx) by checking if error.response exists; if error.response is undefined, the request was blocked (CORS) or failed to reach the server. Code Logic that you can apply is that Use if (!error.response) to identify these "blocked" requests, whereas actual HTTP errors (like 400 or 404) will always contain the response object with the status code. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hello Everyone, I have been recently working with axios to find the url's which have CORS issue. but while using axios I have noticed that url which have CORS issue are returned as BAD request error without any specific error message (i.e. in the network tab I can see 200 status but in react app the api call return's bad request error) and for bad/incorrect url's as well it return BAD request error. can anyone please help me find how can I use axios to differentiate between url's with CORS and url's with bad request.

All reactions