Here you can discuss and ask help about the course related lesson.
Tips for quick help:
- How to post Code
- Mention the lesson name, Example: “Cloud Code - Triggers”
- Screenshot about the console error if possible.
Here you can discuss and ask help about the course related lesson.
Tips for quick help:
Hey Chris,
Awesome to have you on board for this course!
I recently went through your trading course and you are precise and concise with your wording and super easy and digestible to follow.
The ACL part was great - something I have not yet controlled over the last few months of writing Moralis Dapps.
Lesson: Users Part 1
I currently get a 405 status error when I try to login using metamask. I have git clone the 201 repository and opened the wallet.html in live server.
This is my error
Hey @Eleanor_Tay, hope you are well.
Try changing the source of your moralid sdk in your index.html
file.
Change for: <script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>
Let me know if it works.
Carlos Z
Can you please share your code? remember to post it on the following way:
https://academy.moralis.io/lessons/how-to-post-code-in-the-forum
Carlos Z
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BOILER PLATE</title>
<!-- ESSENTIAL start -->
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- ESSENTIAL end -->
<!-- WALLET CONNECT -->
<script src="https://github.com/WalletConnect/walletconnect-monorepo/releases/download/1.6.2/web3-provider.min.js"></script>
<style>
pre{ font-size:20px; cursor: pointer; }
.footer { position: absolute; bottom: 0; width: 100%; height: 60px; line-height: 60px; background-color: #f5f5f5; }
</style>
</head>
<body>
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-4">BOILER PLATE</h1>
<button id="logout_button">Logout</button>
<button id="login_button">Sign in</button>
<!-- <button id="login_button_wc">Sign in with Wallet Connect</button> -->
</div>
</div>
<div class="container">
<div class="my-4" id="content">
<div class="h2">
PRIVATE TEXT: Logged in content goes here
</div>
</div>
<div>
<p>
Public Text</p>
</div>
</div>
<footer class="footer">
<div class="container">
<a href="#" class="text-muted">Footer Text/Link</a>
</div>
</footer>
<script>
// (async function(){
// const serverUrl = "SERVER_URL"
// const appId = "APP_ID"
// await Moralis.start({serverUrl, appId})
// })()
// Initialise Moralisq
const serverUrl = "SERVER_URL"
const appId = "APP_ID"
Moralis.start({serverUrl, appId})
async function login() {
try {
let currentUser = Moralis.User.current();
if (!currentUser) {
if (typeof screen.orientation === 'undefined') {
// await Moralis.authenticate({ provider: "walletconnect" })
const user = await Moralis.authenticate({
provider: "walletconnect",
signingMessage: "my new custom message: hello",
mobileLinks: [
"rainbow",
"metamask",
"argent",
"trust",
"imtoken",
"pillar",
]
})
}else{
currentUser = await Moralis.authenticate();
}
checkUser();
}
} catch (error) {
console.log(error);
}
}
logout = async () => {
alert('log out clicked')
await Moralis.User.logOut();
checkUser();
}
function checkUser() {
currentUser = Moralis.User.current();
if (currentUser) {
document.getElementById("login_button").style.display = "none";
document.getElementById("logout_button").style.display = "block";
document.getElementById("content").style.display = "block";
} else {
document.getElementById("login_button").style.display = "block";
document.getElementById("logout_button").style.display = "none";
document.getElementById("content").style.display = "none";
}
}
document.getElementById("login_button").onclick = login;
document.getElementById("logout_button").onclick = logout;
checkUser();
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
window.localStorage.removeItem('WALLETCONNECT_DEEPLINK_CHOICE');
}
});
</script>
</body>
</html>```
Is the course missing a video or two that pertain to the ‘Connect the SDK’ and ‘Boiler Plate’ sections of the documentation? The ‘Users Part 1’ lesson starts out talking about having covered the ‘Crypto Login’, ‘EMail Login’ when the boilerplate code was built previously.
All i did was to add my server url and apikey at code line 60:
const serverUrl = "https://eeeeeeeee.usemoralis.com:2053/server"
const appId = "eeeeeeeeeeeeeeeeeeeeee"
Moralis.start({serverUrl, appId})
you can get yours in https://admin.moralis.io/servers and then in “view details” button.
Carlos Z
Hey @CryptoFanUS, hope you are well.
It’s indeed missing, since we have it on the documentation, https://docs.moralis.io/moralis-server/getting-started/connect-the-sdk
You can also check this lesson from the new JS course which explain in detail the missing part from this course, https://academy.moralis.io/lessons/moralis-login
Hope this works for you
Carlos Z
@thecil, I believe the boilerplate project lesson the instructor alludes to is also missing. The continuity is being lost. Can you please check with the course instructor if some videos were missed by mistake? Thanks.
Which course? JS or Moralis?
Carlos Z
@thecil, the Moralis course. The place where the ‘Create a Moralis Server’ lesson leaves off and where the next lesson ‘User Part 1’ picks up is where the problem lies. If you see the first minute of the ‘User Part 1’ lesson, you will see the instructor shows screens that has been previouly built. There are no lessons between the ‘create a server’ and ‘user part 1’ that shows how the screens were built. Not to harp on this but I believe important videos from this course are missing in this section.
Hi CryptoFanUS,
I also got stuck on this step. After some searching through other academy videos, I found this “Hello Moralis” video to be helpful:
https://academy.moralis.io/lessons/hello-moralis-2
This video walked through the steps of creating initial boilerplate files and loading them locally in the browser. Here are some steps I did:
index.html
<!DOCTYPE html>
<html>
<head>
<title>Vanilla Boilerplate</title>
<script src="https://unpkg.com/moralis/dist/moralis.js"></script>
</head>
<body>
<h1>Moralis Hello World!</h1>
<button id="btn-login">Moralis Metamask Login</button>
<button id="btn-logout">Logout</button>
<script type="text/javascript" src="./main.js"></script>
</body>
</html>
Once you can load the index.html in the browser window, you are on your way! Next, add a main.js file for your dapp. See boilerplate code for your main.js file here:
Once I got these two files loaded in the browser, I was able test the functionality in the boilerplate app in my browser. At this point, you should be able to have a similar boilerplate in your browser as the one used in the “User Part 1” video and continue. Hope this helps.
In User Part 2 is missing server side code. When I am loging in I am getting always: “No comments, you may not have permission to view them” because the cloud function on my server does not exist:
async function renderComments() {
let commentSection = document.getElementById('comment-section')
commentSection.innerText = "";
let result;
try {
result = await Moralis.Cloud.run("getData", {}); // <- HERE IS THE ISSUE !
} catch (error) {
commentSection.innerHTML = `
<p>No comments, you may not have permission to view them</p>
`
return;
}
if (result) {
for (let i = 0; i < result.length; i++) {
let _user = result[i].attributes.writer;
console.log(result[i])
const content = document.createElement("div")
content.innerHTML = `
<h6>${result[i].get('content')}</h6>
<p>(Posted by ${_user}: ${result[i].get('createdAt').toLocaleString()})</p>
<hr/>
`
commentSection.appendChild(content)
}
}
}
What should be the cloud function to make it work ?
Hello!
This course is just great!
On lecture “Users Part 1” from [Moralis Web3 dApp Programming] course, I found the following issue (I work under VPN from Chile) :
**moralis.js:26280 **
POST https://31dfkp8lhlji.usemoralis.com:2053/server/functions/getPluginSpecs net::ERR_CONNECTION_TIMED_OUT
Then I changed my location to New York and I successfully connected my wallet.
I changed my location back to Chile, getting the same TimeOut error.
Finally I turned my VPN off and the problem dissappeared.
I would like to know if this is a Testing issue or users will get the same kind of error on production. I think this is very important issue to solve because many users could work under VPN. Otherwise I would have to advice to “turn your VPN off on this site”.
Thanks!
Rodrigo.
Hi Chris,
I noticed your are using a mobile emulator on desktop in one of your videos. Which one would you recommend?
Best,
Matt
Thanks for sharing this!
Hi fam!
Re: Users Part 1
at appx 60 seconds, the instructor talks about an emulator.
Is that like a; gaming emulator for your PC?
How do we operate the dApp we are creating on the PC or laptop, on our mobile device?