hello guys there is a problem with my code where it doesnt connect with metamask here is the code :
const Moralis = require('moralis');
const Moralis = require('moralis/node');
Moralis.initialize("9PmarGeRjGYUJzL0fkLgY7TK4h9r6BryHGBo7wC0");
Moralis.serverURL = 'https://imgvpmtqkpng.moralis.io:2053/server'
init = async () => {
window.web3 = await Moralis.Web3.enable();
// await window.ethereum.send('eth_requestAccounts');
// window.web3 = new Web3(window.web3.currentProvider);
// window.ethereum.enable();
initUser(user);
}
const user = Moralis.User.current();
initUser = async () => {
if (await Moralis.User.current()){
hideElement(usrConnectButton);
showElement(usrPrflButton);
}else{
showElement(usrConnectButton);
hideElement(usrPrflButton);
}
}
login = async() => {
try {
await Moralis.Web3.authenticate();
initUser();
} catch (error) {
window.alert("Та METAMASK эсвэл түрүүвчээ холбоно уу? ");
}
}
hideElement = (element) => element.style.display = "none";
showElement = (element) => element.style.display = "block ";
const usrConnectButton = document.getElementById("btnconnect");
usrConnectButton.onclick=login;
const usrPrflButton = document.getElementById("btnusrinfo");
init();