UNPKG

@replyke/core

Version:

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

23 lines 787 B
import { useCallback } from "react"; import useProject from "../projects/useProject"; import axios from "../../config/axios"; function useFetchUser() { const { projectId } = useProject(); const fetchUser = useCallback(async ({ userId, include, }) => { if (!projectId) { throw new Error("No project specified"); } if (!userId) { throw new Error("Please specify a user ID"); } const response = await axios.get(`/${projectId}/users/${userId}`, { params: { include: Array.isArray(include) ? include.join(",") : include, }, }); return response.data; }, [projectId]); return fetchUser; } export default useFetchUser; //# sourceMappingURL=useFetchUser.js.map