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

Se hace uso de la función para mostrar un error de axios

parent 7d8e0613
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import { FieldErrors, Resolver, SubmitHandler, useForm } from "react-hook-form";
import { Town, TownFormValues } from "../infraestructure/entities/town";
import { toast } from "react-toastify";
import axios, { AxiosError } from "axios";
import { showErrorAxios } from "../utils/Messages";

const townDatasource = new TownDatasourceProd();
const townRepository = new TownRepositoryProd(townDatasource);
@@ -82,7 +83,7 @@ export const useTown = (forceRenderList?: () => void) => {
              break;
          }
        }
        throw new Error;
        throw new Error();
      }
    }
    toast.promise(
@@ -99,7 +100,10 @@ export const useTown = (forceRenderList?: () => void) => {
      const towns = await townRepository.getTownsByState(stateId, stateName);
      setTownsList(towns);
    }catch(error: any){

      if(axios.isAxiosError(error)){
        error as AxiosError;
        showErrorAxios(error);
      }
    }
  }