UNPKG

@replyke/core

Version:

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

26 lines 1 kB
import { useCallback } from "react"; import useProject from "../projects/useProject"; import useAxiosPrivate from "../../config/useAxiosPrivate"; function useFetchEntityByForeignId() { const axios = useAxiosPrivate(); const { projectId } = useProject(); const fetchEntityByForeignId = useCallback(async ({ foreignId, createIfNotFound, include }) => { if (!projectId) { throw new Error("No projectId available."); } if (!foreignId) { throw new Error("Please pass foreignId"); } const response = await axios.get(`/${projectId}/entities/by-foreign-id`, { params: { foreignId, createIfNotFound, include: Array.isArray(include) ? include.join(",") : include, }, }); return response.data; }, [projectId]); return fetchEntityByForeignId; } export default useFetchEntityByForeignId; //# sourceMappingURL=useFetchEntityByForeignId.js.map