mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-01 23:56:41 +07:00
made node editor use SWR
This commit is contained in:
parent
2eb10c4da7
commit
64cc47a116
5 changed files with 45 additions and 45 deletions
src/utils/hooks/data
15
src/utils/hooks/data/useGetNodeRelated.ts
Normal file
15
src/utils/hooks/data/useGetNodeRelated.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { INode } from '~/redux/types';
|
||||
import useSWR from 'swr';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { ApiGetNodeRelatedResult } from '~/redux/node/types';
|
||||
import { API } from '~/constants/api';
|
||||
import { api } from '~/utils/api';
|
||||
|
||||
export const useGetNodeRelated = (id?: INode['id']) => {
|
||||
const { data, isValidating: isLoading } = useSWR<AxiosResponse<ApiGetNodeRelatedResult>>(
|
||||
API.NODE.RELATED(id),
|
||||
api.get
|
||||
);
|
||||
|
||||
return { related: data?.data.related, isLoading };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue