middle of role page
This commit is contained in:
21
src/lib/hooks/usePermissionsList.js
Normal file
21
src/lib/hooks/usePermissionsList.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { GET_PERMISSIONS_LIST } from "@/core/utils/routes";
|
||||
import useSWR from "swr";
|
||||
import useRequest from "./useRequest";
|
||||
|
||||
export const usePermissionsList = () => {
|
||||
const request = useRequest();
|
||||
|
||||
const fetcher = async (url) => {
|
||||
try {
|
||||
const response = await request(url);
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
|
||||
return useSWR(GET_PERMISSIONS_LIST, fetcher, {
|
||||
keepPreviousData: true,
|
||||
dedupingInterval: 30000,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user