bookmark-folder.ts 550 B

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