Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
578 B
2
Indexable
Never
import { API_USER } from "@/common/constants/api-routes";
import { ApiService } from "@/common/service/api"
import { useQuery } from "@tanstack/react-query"

export async function getUsers(page: number, pageSize?: number) {
  const apiService = new ApiService();
  return await apiService.get(`${API_USER}?page=${page}&pageSize=${pageSize}`)
}

function useGetUsers(page: number, pageSize: number) {
  const query = useQuery({
    queryKey: ['users', page, pageSize],
    queryFn: () => getUsers(page, pageSize)
  })
  return query
}

export default useGetUsers
Leave a Comment