Hello,
I’m stuck at the step where it says " Run index.html
on localhost
as a web page. The easiest way is by using the live server extension Visual Studio Code. Just right click on index.html
and select Open with Live Server
."
When I right click on index.html, I don’t see Open with Live Server.
Below is my code;
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
<h1>Gas Stats With Moralis</h1>
<button id="btn-login">Moralis Login</button>
<button id="btn-logout">Logout</button>
<script>
// connect to Moralis server
const serverUrl = "https://cvtgsjgr0ff6.usemoralis.com:2053/server";
const appId = "xEixD4bwBHbvx9HAiOj9SsqchNEIauNw40RIZK51";
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);
}
async function logOut() {
await Moralis.User.logOut();
console.log("logged out");
}
document.getElementById("btn-login").onclick = login;
document.getElementById("btn-logout").onclick = logOut;
</script>