fetchStateReceiver was created to handle the data fetching process. Information about the data fetching process and fetch results are saved in the state selected by us.
This helper method is integrated with useFetchState hook.
Javascript Typescript
Copy import { fetchStateReceiver } from 'eventrix' ;
import axios from 'axios' ;
const fetchUsersListReceiver = fetchStateReceiver (
'users' ,
(fetchParams) => {
return axios .get ( 'http://domain.com/users' , fetchParams)
.then (({data: usersList}) => {
return usersList;
});
}
);
export default receiver;
Copy import { fetchStateReceiver } from 'eventrix' ;
import axios from 'axios' ;
import { User , UserFetchParams} from './interfaces' ;
const fetchUsersListReceiver = fetchStateReceiver < UserFetchParams , User []>(
'users' ,
(fetchParams) => {
return axios .get ( 'http://domain.com/users' , fetchParams)
.then (({data: usersList}) => {
return usersList;
});
}
);
export default receiver;