This is my current setup, I’m only triggering the useMoralisQuery whenever the user is authenticated, but it’s giving me an error that the user “get” is null…
const getFavorites = useMoralisQuery(
"Favorites",
(query) => query.contains("favorites", user.get("ethAddress")),
[],
{ autoFetch: false }
);
const fetchFavorites = () => {
if (isAuthenticated)
getFavorites.fetch({
onSuccess: (favorites) => {
// The object was retrieved successfully.
console.log(favorites)
setFav(favorites)
},
onError: (error) => {
// The object was not retrieved successfully.
// error is a Moralis.Error with an error code and message.
},
});
else
toast.error("You must connect your wallet.")
};
useEffect(() => {
if (isAuthenticated)
fetchFavorites();
console.log(isAuthenticated)
}, [isAuthenticated])