Just started with github code but could not get it working because of this error.
maybe you are looking at a version of code that uses an old syntax, a lot have changed recently on Moralis SDK.
Please share the code you used
I assume you want to use const { Moralis } = useMoralis();
?
You can find great working examples here
I am using below code in HTML
`<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.87.0">
<title>The Login Component</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/sign-in/">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="signin.css">
<link rel="stylesheet" href="style.css">
<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 class="text-center">
<main class="form-signin">
<img class="mb-4" src="wallet-png.png" alt="" width="150" height="150">
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
<div class="form-floating">
<input type="text" class="form-control" id="user-username" placeholder="Username">
<label for="user-username">Username</label>
</div>
<div class="form-floating">
<input type="email" class="form-control" id="user-email" placeholder="[email protected]">
<label for="user-email">Email address</label>
</div>
<button id="btn-login" class="w-100 btn btn-lg btn-primary" type="submit">Login or Register</button>
<p class="mt-5 mb-3 text-muted">© 2017–2021</p>
</main>
<script src="main.js"></script>
</body>
</html>`
and main.js as below
console.log(‘hello world’);
// MY SERVER
Moralis.initialize(“APP-ID”);
Moralis.serverURL = “SERVER”;
let homepage = “http://localhost/webwallet/index.html”;
let dashboard = “http://localhost/webwallet/dashboard.html”;
// REDIRECT USER BASED ON STATUS
if (Moralis.User.current() == null && window.location.href != homepage) {
document.querySelector('body').style.display = 'none';
window.location.href = "index.html";
}
You can ignore this message, you are not using typescript, so there is no any real problem.
I suggest you to update your syntax:
Moralis.initialize(“APP-ID”);
Moralis.serverURL = “SERVER”;
to:
const serverUrl = "https://xxxxx.grandmoralis.com:2053/server";
const appId = "YOUR_APP_ID";
Moralis.start({ serverUrl, appId });
2 Likes