UNPKG

@replyke/core

Version:

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

29 lines 1.06 kB
import { useCallback } from "react"; import useAxiosPrivate from "../../../config/useAxiosPrivate"; import useProject from "../../projects/useProject"; import { useUser } from "../../user"; function useFetchFollowStatus() { const axios = useAxiosPrivate(); const { projectId } = useProject(); const { user } = useUser(); const fetchFollowStatus = useCallback(async (props) => { const { userId } = props; if (!projectId) { throw new Error("No project specified"); } if (!user) { throw new Error("No user is logged in"); } if (!userId) { throw new Error("No user ID was provided"); } if (userId === user.id) { throw new Error("Users don't follow themselves"); } const response = await axios.get(`/${projectId}/users/${userId}/follow`); return response.data; }, [axios, projectId, user?.id]); return fetchFollowStatus; } export default useFetchFollowStatus; //# sourceMappingURL=useFetchFollowStatus.js.map