Problem with the previewing

Hi, their guys so I am currently following along with this tutorial, however, as I began there seemed to be a problem when I tried to preview the website. I will post the code I’ve written so far and will continue with the tutorials, for now, any help would be appreciated.

JavaScript

Moralis.initialize("gb3kWC7bGfCmgDVXEUwW2vmeyWvIW0ARM2r0pQiu");
Moralis.serverURL = 'https://evlxvcltvb1c.usemoralis.com:2053/server'

init = async () => {

    window.web3 = await Moralis.Web3.enable();

    innitUser();

}

innitUser = async () => {

    if (await Moralis.User.current()) {

        hideElement(userSyncButton);

        showElement(userProfileButton);

    }else{

        showElement(userSyncButton);

        hideElement(userProfileButton);

    }

}

login = async () => {

    try {

        await Moralis.Web3.authenticate();

        innitUser ();

    } catch (error) {

        alert(error);

    }

}

hideElement = (element) => element.style.display = "none";

showElement = (element) => element.style.display = "block";

const userSyncButton = document.getElementById("btnSync");

userSyncButton.oneclick = login;

const userProfileButton = document.getElementById("btnUserProfile");

init();

HTML

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <div>

        <button id= "btnSync">Sync Wallet</button>

        <button id="btnUserProfile">Profile</button>

    </div>

    <script src="https://cdn.jsdeivr.net/npm/[email protected]/dist/web3.min.js"></script>

    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>

    <script src="main.js"></script>

</body>

</html>

you can see here how to post code on forum: READ BEFORE POSTING - How to post code in the forum

1 Like

hi @JDBoyd
the code that you have it is a little outdated and that syntax with Moralis.initialize doesn’t work with latest SDK version.

You can see an updating example here


on how to use Moralis.start
1 Like

Thanks @cryptokid much appreciated :1st_place_medal: