Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3481 | Rev 3484 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

import { api } from '@api';
import { useApi } from './useApi';
import { useAlert } from './useAlert';

const getResources = async (url) => {
  return await api.get(url);
};

export function useFetch(url) {
  const { showError } = useAlert();

  const { data, loading, execute } = useApi(getResources(url), {
    autoFetch: true,
    onSuccess: (response) => console.log({ response }),
    onError: (error) => showError(error)
  });

  return {
    data,
    loading,
    refetch: execute
  };
}