I’m trying to grab the current users ethAddress and use it to set data in another object but wont output the address whatsoever.
import { useNewMoralisObject, useMoralis } from "react-moralis";
export default function App() {
const { save } = useNewMoralisObject("Monster");
const { user } = useMoralis();
const updateObject = async () => {
const data = {
strength: 1024,
energy: 1337,
owner: user.attributes.ethAddress
};
save(data, {
onSuccess: (monster) => {
monster.set("canFly", true);
monster.set("strength", 1338);
return monster.save();
},
});
};
return <button onClick={updateObject}>Call The Code</button>;
}
It displays the address perfectly when I use {user.attributes.ethAddress} inside a render function.
I’ve also tried user.get(“ethAddress”) with no success.
Any help would be appreciated!