UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

24 lines 864 B
import { useCallback } from "react"; import useProject from "../projects/useProject"; import useAxiosPrivate from "../../config/useAxiosPrivate"; function useFetchEntity() { const axios = useAxiosPrivate(); const { projectId } = useProject(); const fetchEntity = useCallback(async ({ entityId, include }) => { if (!projectId) { throw new Error("No projectId available."); } if (!entityId) { throw new Error("Please pass an entityId"); } const response = await axios.get(`/${projectId}/entities/${entityId}`, { params: { include: Array.isArray(include) ? include.join(",") : include, }, }); return response.data; }, [projectId]); return fetchEntity; } export default useFetchEntity; //# sourceMappingURL=useFetchEntity.js.map