UNPKG

@replyke/core

Version:

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

25 lines 911 B
import { useCallback } from "react"; import useProject from "../projects/useProject"; import axios from "../../config/axios"; function useFetchSpaceChildren() { const { projectId } = useProject(); const fetchSpaceChildren = useCallback(async ({ spaceId, page = 1, limit = 20, include }) => { if (!projectId) { throw new Error("No projectId available."); } if (!spaceId) { throw new Error("Please pass a spaceId"); } const response = await axios.get(`/${projectId}/spaces/${spaceId}/children`, { params: { page, limit, include: Array.isArray(include) ? include.join(",") : include, }, }); return response.data; }, [projectId]); return fetchSpaceChildren; } export default useFetchSpaceChildren; //# sourceMappingURL=useFetchSpaceChildren.js.map