Please , what am i doing wrong, the subscription is not working, i mean Live Queries

const { data } = useMoralisQuery< MainTweetsProps>(  "Tweets", (query) => query.descending("createdAt"));

//const { data } = useMoralisQuery< MainTweetsProps>(  "Tweets", (query) => //query.descending("createdAt"),
//    [],
//    { autoFetch: true }
//  );
that did not work 

useEffect(() => {
      () => (mounted.current = false);
    }, []);
   
    useEffect(() => {
      const fetchData = async () => {
        const result = JSON.parse(JSON.stringify(data));
    setTweets(result);
  
      };
    
      isInitialized && fetchData();
    }, [data, isInitialized]);  

    useEffect(() => {
      const fetchData = async () => {
    let query = new Moralis.Query('Tweets');
    let subscription=await query.subscribe();
    subscription.on("create", (obj)=>{
      console.log("obj :>>", obj);
      tweets.push(obj);
      setTweets(tweets); 
    })
      };
      isInitialized && fetchData();
    }, [Moralis.Query, isInitialized, tweets]); 

try on update here in case that Tweets table is created from an event sync

1 Like

i have already tried it, and it was same result,

try to add more logging here, to see if the function gets called first, like adding a console log before
let query = new Moralis.Query('Tweets');

then try with subscription.on("update"

I guess that there are items updated in Tweets table

1 Like