How to catch and handle error response 422 with Redux/Axios?

Example

getUserList() {
    return axios.get("https://stackoverflow.com/users")
      .then(response => response.data)
      .catch(error => {
        if (error.response) {
          console.log(error.response);
        }
      });
  }

Check the error object for response, it will include the object you’re looking for so you can do error.response.status

enter image description here

https://github.com/mzabriskie/axios#handling-errors

Leave a Comment