Skip to main content

Overview

Returns a function that fetches the paginated list of connection requests that other users have sent to the current authenticated user and that have not yet been accepted or declined.

Usage Example

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

function IncomingRequests() {
  const fetchReceivedPendingConnections = useFetchReceivedPendingConnections();
  const acceptConnection = useAcceptConnection();
  const [requests, setRequests] = useState([]);

  useEffect(() => {
    fetchReceivedPendingConnections({ page: 1 }).then((res) => {
      setRequests(res.data);
    });
  }, []);

  return (
    <ul>
      {requests.map(({ id, user }) => (
        <li key={id}>
          {user.name} wants to connect
          <button onClick={() => acceptConnection({ connectionId: id })}>Accept</button>
        </li>
      ))}
    </ul>
  );
}

Parameters

The hook returns a function. That function accepts:
page
number
Page number to fetch. Defaults to 1.
limit
number
Number of results per page. Defaults to 20.

Returns

Returns a PaginatedResponse containing pending connection entries:
data
PendingConnection[]
Array of pending connection entries.
pagination
object
Pagination metadata including page, pageSize, totalPages, totalItems, and hasMore.