Skip to main content

Overview

Returns a function that fetches the paginated list of users that a given user follows, identified by userId. This is a public endpoint — authentication is not required. For fetching your own following list, see useFetchFollowing.

Usage Example

import { useFetchFollowingByUserId } from "@replyke/react-js";

function UserFollowing({ userId }: { userId: string }) {
  const fetchFollowingByUserId = useFetchFollowingByUserId();
  const [following, setFollowing] = useState([]);

  useEffect(() => {
    fetchFollowingByUserId({ userId, page: 1 }).then((res) => {
      setFollowing(res.data);
    });
  }, [userId]);

  return (
    <ul>
      {following.map(({ followId, user }) => (
        <li key={followId}>{user.name}</li>
      ))}
    </ul>
  );
}

Parameters

The hook returns a function. That function accepts:
userId
string
required
The ID of the user whose following list to fetch.
page
number
Page number to fetch. Defaults to 1.
limit
number
Number of results per page. Defaults to 20.

Returns

Returns a PaginatedResponse containing an array of following entries:
data
FollowingWithFollowInfo[]
Array of following entries.
pagination
object
Pagination metadata including currentPage, totalPages, totalCount, hasNextPage, and hasPreviousPage.