React-moralis, function useMoralisQuery, searching item by currentPatientWalletId address

606 views Asked by At

I'm trying to query patient's consultation data via currentPatientWalletId which is a variable am passing to the useMoralisQuery hook,butit cant.bt once i hard code the currentPatientWalletId it works.please help.

import React,{useEffect,useState} from 'react';
import { useMoralis, useMoralisQuery } from 'react-moralis';
function PatientConsultationReport({currentPatientWalletId}) {
    const { isAuthenticated,Moralis,user,isWeb3Enabled,authenticate,enableWeb3 } = useMoralis();
    const { fetch,data,isLoading,error } = useMoralisQuery(
        "consultation",(query) => query.equalTo(
        "patientWalletId",currentPatientWalletId),[],{live:true} );     
return (
    <div>
        <div>PatientConsultationReport</div> <hr />        
         {
                    error ? (<span></span>):
                    isLoading ? ( <span></span>):
                      
                      (<pre>{JSON.stringify(data, null, 2)}</pre>)
                }
    </div>
  )
}

export default PatientConsultationReport
1

There are 1 answers

1
DENIS WACHIRA On BEST ANSWER

Your code seams to be syntax correct. Console log the currentPatientId wallet and check its case. Moralis database usually stores the ethAddress in lowercase, so that might be the problem. Check out this article. https://forum.moralis.io/t/the-future-of-the-javascript-sdk/14501