bookmark-folder.ts 524 B

123456789101112131415
  1. import { SWRResponse } from 'swr';
  2. import useSWRImmutable from 'swr/immutable';
  3. import { apiv3Get } from '~/client/util/apiv3-client';
  4. import { BookmarkFolderItems } from '~/interfaces/bookmark-info';
  5. export const useSWRxBookmarkFolderAndChild = (userId?: string): SWRResponse<BookmarkFolderItems[], Error> => {
  6. return useSWRImmutable(
  7. userId != null ? `/bookmark-folder/list/${userId}` : null,
  8. endpoint => apiv3Get(endpoint).then((response) => {
  9. return response.data.bookmarkFolderItems;
  10. }),
  11. );
  12. };