Commit 3c8c7f43 authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

Se agregó la posibilidad de refrescar los datos de una peticion get

parent 93e00654
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
import { useEffect, useState } from "react";
import { ApiRequestStatus } from "../common/constants/api_request_states";
import { set } from "react-hook-form";

export const useGet = <T>(callback: () => Promise<T>) => {
    const [data, setData] = useState<T | null>(null);
@@ -9,6 +10,7 @@ export const useGet = <T>(callback: () => Promise<T>) => {

    const fetchData = async () => {
        try {
            await setLoading();
            const response = await callback();
            setData(response);
            setRequestStatus(ApiRequestStatus.SUCCESS);