
Hey, I'm currently working a nextJs projekt with appwrite and tried to connect to the 'account' channel but im not getting any response even on changes. After initial load i have opened another tab where i make changes to the user but nothing came in the page component. On the network tab there is the realtime connection pending but has no data and after a while its fail and try to esteblish a new connection.
'use client'
import React, { useEffect, useState } from 'react'
import { Client, Account } from 'appwrite';
import Connection from '@/lib/appwrite';
const Page = () => {
const client = Connection();
const account = new Account(client);
const [user, setUser] = useState<any>(null);
useEffect(() => {
const fetchUser = async () => {
try {
const userData = await account.get();
setUser(userData);
} catch (error) {
console.error('Error fetching user:', error);
}
};
fetchUser();
const unsubscribe = client.subscribe('account', (response) => {
console.log('Account update received:', response);
fetchUser();
});
return () => unsubscribe();
}, []);
return (
<div>Page asd</div>
)
}
export default Page
Recommended threads
- Unable to migrate from self hosted to cl...
I'm trying to migrate my project that's currently self hosted running on version 1.6.0. I was able to migrate 3 other projects that had auth, functions, and dat...
- Can multiple functions exist in one Appw...
Can I add more than one function in the `src/main.js` file of an Appwrite cloud function? What if the different functions depend on two separate events, speci...
- Postman function call
Hi I'm trying to call a locally running function, which requires auth, in headers I'm passing jwt token with key as 'x-appwrite-user-jwt", but upon logging req....
