Commit d8e9e0bc authored by Omar Luna Hernández's avatar Omar Luna Hernández
Browse files

Se crea una función para mostrar mensajes de error de axios

parent 5d3f79f4
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
import axios, { AxiosError } from "axios";
import { toast } from "react-toastify";

export const showErrorAxios = (error: AxiosError) => {
  let message = "";
  switch(error.code){
    case(axios.AxiosError.ERR_BAD_REQUEST):
      message = "Acceso no autorizado";
      break;
    case(axios.AxiosError.ERR_NETWORK):
      message = "Conexión con el servidor fallida";
      break;
  }
  toast.error(message, {
    position: "bottom-right",
    autoClose: 1500,
    hideProgressBar: false,
    closeOnClick: true,
    pauseOnHover: false,
    draggable: true,
    progress: undefined,
    theme: "colored"
  });
}
 No newline at end of file