Axios 400 Bad request in React
You could console.log(error.response)
in your catch block to get a more human-readable object.
Edit: axios
errors come in three types: message
, request
and response
. To make sure you are handling all possible errors, you could use a conditional block:
if (error.response){//do something}else if(error.request){//do something else}else if(error.message){//do something other than the other two}