[SOLVED] ethAdress undefined

Hello everyone,

I was following the tutorial on Building Your First Dapp. All was good until we get to user.get(ethAddress).
For some reason it is undefined and I can’t find why. I am not an experienced dev so I will ask for your guidance.

I did manage to connect the user to the database. Login and logout function work well, but for some reason it’s not the case for (ethAddress)
image

Here is the login function

// log IN the user 
async function login() {
    let user = Moralis.User.current();
    if(!user){
        user = await Moralis.authenticate({ singinMessage: "Log in using Moralis"})
        .then(function (user) {
            console.log("logged in user", user);
            console.log(user.get(ethAddress)); 
            document.getElementById("adress-Text").innerHTML = user.get(ethAdress);
        })// end of then() 
        .catch(function (error) {
            console.log(error);
        })
    }//end of if()

}//end of login()

You are missing some quotations.
It should be:
console.log(user.get('ethAddress'))
note the 'ethAddress’

1 Like

maybe you have to use something like user.get("ethAddress")

Yup was that indeed. Thanks for answering fast. :+1: