This is my code
JS
const userAddress = user.get('ethAddress');
document.getElementById("add").innerHTML = userAddress;
HTML
<div id="add"></div>
This is my code
JS
const userAddress = user.get('ethAddress');
document.getElementById("add").innerHTML = userAddress;
HTML
<div id="add"></div>
it looks like this works for me, you could also add a console.log(userAddress)
to see what you have there
Thanks but
i want to display to my html for user to see the address connected tooβ¦
Did the user already authenticated with Moralis.authenticate()
?
yes
login = async () => {
await Moralis.Web3.authenticate()
.then (async function (user) {
console.log('login');
console.log(Moralis.User.current());
console.log(user.get('ethAddress'))
console.log(user.get('_user.id'))
console.log(user.get('createdAt'))
console.log(user.get('username'))
user.set("name", document.getElementById('user-username').value);
user.set("email", document.getElementById('user-email').value);
await user.save();
window.location.href = "dashboard.html";
you can write this as:
login = async () => {
user = await Moralis.Web3.authenticate()
console.log('login');
console.log(Moralis.User.current());