Record not found on query React JS

Hi! I’m trying to fetch a specific user from the database. but I get the following error: “Object not found”. My goal is to get a specific user based on input value. I’ve tried hardcoding the username as well but without any result. This is what I have so far:


function List()

{

const[username, setUsername] = useState('')

const {fetch,data, error, isLoading} = useMoralisQuery("User",q=>q.get('username') ===username)

const[wallet, setWallet] = useState('')

    return(

           

                <div className="list_box">

                 <div className="title_box p-3 d-flex justify-content-center">

                    <label>Conversations</label>

                 </div>

                 <div className="search_box d-flex col p-3">

                    <input type="search" className="search_input row" placeholder="Search" onChange={(e)=>setUsername(e.target.value)}></input>

                    <div className="position-relative w-25" onClick={fetch}>

                   <img src={blobButton} className="svg_button position-absolute" alt="blob button"/>

                   <FontAwesomeIcon className="icon_message_writing" icon={faEdit} />

                   </div>

                </div>

                </div>  

    )

}
1 Like

Hi @HenryJones

Try this:

const { data, error, isLoading } = useMoralisQuery("User", user=>
  user.equalTo("username", username).limit(1),
);

Awesome, thank you! Can you send me a link with the documentation for the query functions? I can’t seem to find them anywhere.

Take a look at:


https://docs.moralis.io/moralis-server/database/queries
1 Like