UNPKG

@replyke/core

Version:

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

25 lines 856 B
import { useCallback } from "react"; import useProject from "../projects/useProject"; import axios from "../../config/axios"; function useFetchComment() { const { projectId } = useProject(); const fetchComment = useCallback(async ({ commentId, include }) => { if (!projectId) { throw new Error("No project specified"); } if (!commentId) { throw new Error("No comment ID passed"); } const params = {}; if (include) { params.include = Array.isArray(include) ? include.join(',') : include; } const response = await axios.get(`/${projectId}/comments/${commentId}`, { params, }); return response.data; }, [projectId]); return fetchComment; } export default useFetchComment; //# sourceMappingURL=useFetchComment.js.map