<script src="xx"></script>
<script>
Imports js file or library https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script . It’s not for Moralis initialization.
Your code should be like this:
> <html>
> <head>
> <!-- Moralis SDK code -->
> <script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
> </head>
>
> <body>
> <h1>Try it once</h1>
> <button id="btn-login">Moralis Login</button>
> <button id="btn-logout">Logout</button>
> <script>
> // connect to Moralis server
const serverUrl = "https://xxxxx/server";
const appId = "YOUR_APP_ID";
Moralis.start({ serverUrl, appId });
>
> // add from here down
> async function login() {
> let user = Moralis.User.current();
> if (!user) {
> user = await Moralis.authenticate();
> }
> console.log("logged in user:", user);
> }
> initializeApp();
> async function logOut() {
> await Moralis.User.logOut();
> console.log("logged out");
> }
>
> document.getElementById("btn-login").onclick = login;
> document.getElementById("btn-logout").onclick = logOut;
> </script>
> </body>
> </html>