use-post-get-photos-for-user.tsx 573 B

1234567891011121314151617
  1. import { useQuery } from '@tanstack/react-query';
  2. import { photosQueryKeys } from '../photos-query-keys';
  3. import { photosApi, type PostGetPhotosReturn } from '../photos-api';
  4. import type { BaseAxiosError } from '../../../../types';
  5. export const useGetPhotosForUserQuery = (token: string, enabled: boolean) => {
  6. return useQuery<PostGetPhotosReturn, BaseAxiosError>({
  7. queryKey: photosQueryKeys.getPhotosForUser(token),
  8. queryFn: async () => {
  9. const response = await photosApi.getPhotosForUser(token);
  10. return response.data;
  11. },
  12. enabled
  13. });
  14. };