After successful login with metamask
Moralis dashboard showing undefined user details after login in with metamask , couldn’t fetch address,username and email
HTML CODE
<div class="card-body">
<label for="user-username">Username</label>
<div class="mb-3">
<input type="text" id="user-username" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="Username-addon">
</div>
<label for="user-email">Email</label>
<div class="mb-3">
<input type="email" id="user-email" class="form-control" placeholder="Email" aria-label="Email" aria-describedby="email-addon">
</div>
<div class="text-center">
<button type="submit" id="btn-login" class="mt-4 mb-0 btn bg-gradient-info w-100">Sign in</button>
</div>
</div>
JAVASCRIPT CODE
login = async () => {
user = await Moralis.Web3.authenticate().then(async function (user) {
console.log('logged in');
user.set("name", document.getElementById('user-username').value);
user.set("email", document.getElementById('user-email').value);
await user.save();
window.location.href = "dashboard.html";
})
}
document.querySelector('#btn-login').onclick = login;