I would like to extend this basic javascript boilerplate code with the accountChanged function
const unsubscribe = Moralis.onAccountsChanged()
console.log(unsubscribe);
here is a the code
/** Connect to Moralis server */
const serverUrl =
const appId =
Moralis.start({ serverUrl, appId });/** Add from here down *
async function login() {
let user = Moralis.User.current();
if (!user) {
try {
user = await Moralis.authenticate({ signingMessage: âHello World!â })
console.log(user)
console.log(user.get(âethAddressâ))
} catch (error) {
console.log(error)
}
}
}const unsubscribe = Moralis.onAccountsChanged(function(accounts) {
console.log(account);
});
async function logOut() {
await Moralis.User.logOut();
console.log(âlogged outâ);
}document.getElementById(âbtn-loginâ).onclick = login;
document.getElementById(âbtn-logoutâ).onclick = logOut;