Rev 3483 | 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,
onError: (err) => showError(err.message)
});
return {
data,
loading,
refetch: execute
};
}