Issue with Amity SDK: "Error: Connect client first"

I am currently facing an issue with the Amity SDK in my Next.js application, and I’d appreciate your help in resolving it.

I am using the TypeScript SDK of Amity and encountering the following error: “Error: Amity SDK (800000): Connect client first.” The error is raised when I try to retrieve follow information using the UserRepository.Relationship.getFollowInfo function.

Code Snippet: Here is a simplified version of the relevant code:

const sessionHandler: Amity.SessionHandler = {
  sessionWillRenewAccessToken(renewal) {

const handleConnect = async (userId: string, displayName: string) => {
  console.log(userId, displayName);

  return Client.login({ userId, displayName }, sessionHandler)
    .then(() => {
      console.log('handleConnect completed');

useEffect(() => {
  if (user) {
    handleConnect(`${user?.email}`, `${user?.name}`);
    console.log("handleConnect completed");
}, [user]);

const [followInfo, setFollowInfo] = useState<Amity.FollowInfo>();

useEffect(() => {
    UserRepository.Relationship.getFollowInfo(id as string, ({ data: followInfo, loading, error }) => {


  return () => disposers.forEach(fn => fn());
}, [id]);

@jethaniya_20 The error might occur from calling the sdk function before connecting to amity session successfully. Can you try calling UserRepository.Relationship.getFollowInfo after sessionState equal to established. You can check the session state status with this code

  const [sessionState, setSessionState] = useState('');
  useEffect(() => {
    return Client.onSessionStateChange((state: Amity.SessionStates) => setSessionState(state));
  }, []);