const loadUsers = () => dispatch => { dispatch(setLoading()); Api.getUsers() .then(users => dispatch(setUsers(users))) .catch(() => dispatch(setError())); }
const getUsers = (amount) => (dispatch) => { loading(true); axios({ method: "get", url: "https://reqres.in/api/users", }) .then((res) => { dispatch(loading(false)); dispatch(setUsers(res.data)); }) .catch((err) => { dispatch(loading(false)); dispatch(setError(err)); // alert("an error occur"); }); }