I am trying to follow along with the Rarible clone tutorial, but when making use of async await statements Moralis adds
const { default: Moralis } = require("moralis/types");
to the top of the main.js file. But it seems that require() is not recognized by default in the browser. How to fix this?
I tried this guide but I still get the error
This is the full main.js file:
const { default: Moralis } = require("moralis/types");
//Moralis init code
const serverUrl = "https://y9hsm4runbtm.usemoralis.com:2053/server";
const appId = "rt6pVD9k1xm0d1DiZMWMSFhg3mBe3mxTHkrBDYh6";
Moralis.start({ serverUrl, appId });
// Authentication code
async function login() {
    let user = Moralis.User.current();
    if (!user) {
        user = await Moralis.authenticate({ signingMessage: "Log in using Moralis" })
            .then(function (user) {
                console.log("logged in user:", user);
                console.log(user.get("ethAddress"));
            })
            .catch(function (error) {
                console(error);
            });
    }
}
async function logOut() {
    await Moralis.User.logOut();
    console.log("logged out");
}
openUserProfile = async () => {
    user = await Moralis.User.current();
    if (user) {
        showElement(userProfile);
    } else {
        login();
    }
}
// Adding button functionality
loginBtn = document.getElementById("btnLogin");
loginBtn.onclick = login;
logoutBtn = document.getElementById("btnLogout");
logoutBtn.onclick = logOut;
userProfileBTN = document.getElementById("btnProfile");
userProfileBTN.onclick = openUserProfile;
hideElement = (element) => element.style.display = "none";
showElement = (element) => element.style.display = "block";
        
      
    