bookmark.ts 510 B

12345678910111213141516
  1. import useSWR, { SWRResponse } from 'swr';
  2. import { apiv3Get } from '../client/util/apiv3-client';
  3. import { IBookmarkInfo } from '../interfaces/bookmark-info';
  4. export const useSWRBookmarkInfo = (pageId: string): SWRResponse<IBookmarkInfo, Error> => {
  5. return useSWR(
  6. `/bookmarks/info?pageId=${pageId}`,
  7. endpoint => apiv3Get(endpoint).then((response) => {
  8. return {
  9. sumOfBookmarks: response.data.sumOfBookmarks,
  10. isBookmarked: response.data.isBookmarked,
  11. };
  12. }),
  13. );
  14. };