Hi can anyone help?
I’m in VS code trying to replicate one of @ivan 's youtube videos on moralis web 3. I’ve copied the code but server, Serving HTTP on :: port 8000 (http://[::]:8000/) is saying It looks like the webpage at http://[::]:8000/ might be having issues or it may have moved permanently to a new web address.
It will not open when I refresh. when looking at errors in the console it is saying the following which i’m not sure if it’s related as i’ve copied and checked the code.
Uncaught TypeError: Cannot set property ‘onclick’ of null
at main.js:47
the code is as follows:
Moralis.initialize(“IapOWU3RooznWc8ustC4FZFRjzhyb5HxC9MsiO6J”);
Moralis.serverURL = ‘https://7eikkqudhrjg.moralis.io:2053/server’
// ABOVE CLOSED
// Initiate Moralis Function
init = async () => {
window.web3 = await Moralis.Web3.enable ();
initUser ();
}
// Closed
// Initiate User
initUser = async () => {
if (await Moralis.User.current ()) {
// LINE BELOW: If user is logged in, hide the connect button but show profile button
hideElement (userConnectButton);
showElement (userProfileButton);
// LINE BELOW: Or if the user is not logged in do the opposite and show connect button but not the profile button
}else {
showElement (userConnectButton);
hideElement (userProfileButton);
}
}
// LOGIN FEATURE, Also authenticates METAMASK
login = async () => {
try {
await Moralis.Web3.authenticate ();
initUser ();
} catch (error) {
alert (error);
}
}
// HIDE ELEMENTS
hideElement = (element) => element.style.display = “none”;
showElement = (element) => element.style.display = “block”;
// CLOSED
// CONNECTING USER BUTTONS TO JAVASCRIPT, Allowing user to login
const userConnectButton = document.getElementById (“btnConnect”);
userConnectButton.onclick = login;
const userProfileButton = document.getElementById (“btnUserInfo”);
init ();
// ABOVE CLOSED
If anyone on the off-chance could guide me in the right direction it would be so much appreciated.
Thanks guys