Rev 3494 | Rev 3497 | 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';import { useEffect } from 'react';const getResources = async (url, config) => {return await api.get(url, config);};export function useFetch(url, config = { params: undefined }) {const { showError } = useAlert();const { loading, data, error, execute } = useApi(getResources);useEffect(() => {execute(url, config);}, [url, config]);useEffect(() => {if (error) showError(error);}, [error]);return {data,loading,refetch: () => execute(url, config)};}