1
0
Fork 0
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:
Fedor Katurov 2021-11-21 21:23:07 +07:00
parent 2eb10c4da7
commit 64cc47a116
5 changed files with 45 additions and 45 deletions
src/utils/hooks/data

View 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 };
};