29 lines
754 B
JavaScript
29 lines
754 B
JavaScript
import {GET_PROVINCE_LIST} from "@/core/data/apiRoutes";
|
|
import useRequest from "@/lib/app/hooks/useRequest";
|
|
import useSWR from "swr";
|
|
|
|
const useProvince = () => {
|
|
const requestServer = useRequest({auth: true, notification: false})
|
|
|
|
//swr config
|
|
const fetcher = (...args) => {
|
|
return requestServer(args, 'get').then(({data}) => {
|
|
return data;
|
|
}).catch(() => {
|
|
})
|
|
};
|
|
|
|
const {data, isLoading} = useSWR(GET_PROVINCE_LIST, fetcher, {
|
|
revalidateIfStale: false,
|
|
revalidateOnFocus: false,
|
|
revalidateOnReconnect: false
|
|
});
|
|
|
|
return {
|
|
provinceList: data,
|
|
isLoadingProvinceList: isLoading,
|
|
errorProvinceList: !data
|
|
}
|
|
};
|
|
|
|
export default useProvince; |