Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3483 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3481 stevensc 1
import { api } from '@api';
2
import { useApi } from './useApi';
3
import { useAlert } from './useAlert';
4
 
5
const getResources = async (url) => {
6
  return await api.get(url);
7
};
8
 
9
export function useFetch(url) {
10
  const { showError } = useAlert();
11
 
12
  const { data, loading, execute } = useApi(getResources(url), {
13
    autoFetch: true,
14
    onError: (err) => showError(err.message)
15
  });
16
 
17
  return {
18
    data,
19
    loading,
20
    refetch: execute
21
  };
22
}