[SOLVED] useMoralisQuery for 2 reports/tables

Hi, I have 2 tables that I use to show the Transaction of the current users and the Affiliate Earnings that are both under 1 table.

I tried to just duplicate the query but Iโ€™m having an error:

Cannot redeclare block-scoped variable โ€˜dataโ€™.

 const { data } = useMoralisQuery(
  "Transactions", 
  (query) =>
    query
      .equalTo("ethAddress", user?.get('ethAddress')), 
    [],
  );
  const { data } = useMoralisQuery(
    "Transactions", 
    (query) =>
      query
        .equalTo("affiliateCode", user?.get('affiliateCode')), 
      [],
    );

You can give data a different reference name for each which you use instead in your code (oneData / twoData - can give them better names). E.g.

 const { data: oneData } = useMoralisQuery(
  "Transactions", 
  (query) =>
    query
      .equalTo("ethAddress", user?.get('ethAddress')), 
    [],
  );
  const { data: twoData } = useMoralisQuery(
    "Transactions", 
    (query) =>
      query
        .equalTo("affiliateCode", user?.get('affiliateCode')), 
      [],
    );
1 Like

Perfect! Thank you so much, much appreciated!