UNPKG

@replyke/core

Version:

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

27 lines 944 B
import { useCallback } from "react"; import useProject from "../projects/useProject"; import axios from "../../config/axios"; function useFetchCommentByForeignId() { const { projectId } = useProject(); const fetchCommentByForeignId = useCallback(async ({ foreignId, include }) => { if (!projectId) { throw new Error("No project specified"); } if (!foreignId) { throw new Error("No foreign ID passed"); } const params = { foreignId, }; if (include) { params.include = Array.isArray(include) ? include.join(',') : include; } const response = await axios.get(`/${projectId}/comments/by-foreign-id`, { params, }); return response.data; }, [projectId]); return fetchCommentByForeignId; } export default useFetchCommentByForeignId; //# sourceMappingURL=useFetchCommentByForeignId.js.map