Hi im following Chris Bs tutorial on creating your first dapp.
i dont get it, whenever i open up the local host metamask is popping up before i actually give details on username , email and click sign in? When i move from index.html to dahsboard.html it pops up again. Whats up with that?
on top of that - moralis seems to not be able to fetch the username & email and put it in the database.Screen Shot 2021-09-11 at 11.58.44 AM|658x284
code:
index.html
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>
</head>
<body class="text-center">
<main class="form-signin">
<form>
<img class="mb-4" src="../ebb.png" alt="" width="80" height="80">
<h1 class="h3 mb-3 fw-normal">Please sign in</h1>
<div class="form-floating">
<input type="text" class="form-control" id="userUsername" placeholder="Username">
<label for="userUsername">Username</label>
</div>
<div class="form-floating">
<input type="email" class="form-control" id="userEmail" placeholder="[email protected]">
<label for="userEmail">Email address</label>
</div>
<button id="btn-login" class="w-100 btn btn-lg btn-primary" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted">© 2017โ2021</p>
</form>
</main>
<script src="main.js"></script>
</body>
code main.js
console.log("helloworld");
Moralis.initialize("HlFF10yjAlTVOgVKqbGQNsudjMOmlVoe4KOPtUlZ");
Moralis.serverURL = "https://yhitnni921dz.bigmoralis.com:2053/server";
async function login(){
await Moralis.authenticate().then(function (user) {
console.log("logged in");
console.log(Moralis.User.current());
user.set("name", document.getElementById("userUsername").value);
user.set("email", document.getElementById("userEmail").value);
user.save();
console.log("user information saved");
window.location.href = "dashboard.html"
})
}
document.getElementById("btn-login").onclick = login();
appreciate your help
x