Rarible Clone Part 1 (107 Received an error with invalid JSON format from Parse)

I am working on Part 1 of Rarible Clone.
When I try to connect to Metamask, I get an error message and no data is added to the Moralis database.

I think I have the Application ID and Server URL set to the correct values.
I copied the code from github, so it should be fine.

I am using Python 3.9 on an m1 Mac, so is that the problem?
Or am I setting up Moralis incorrectly?
Or is the problem that the Metamask is set to ETH Mainnet before the button is pressed?

main.js

Moralis.initialize("Application ID");
Moralis.serverURL = "SERVER_URL";

init = async () => {
  window.web3 = await Moralis.Web3.enable();
  initUser();
};

initUser = async () => {
  if (await Moralis.User.current()) {
    hideElement(userConnectButton);
    showElement(userProfileButton);
  } else {
    showElement(userConnectButton);
    hideElement(userProfileButton);
  }
};

login = async () => {
  try {
    await Moralis.Web3.authenticate();
    initUser();
  } catch (error) {
    alert(error);
  }
};

hideElement = (element) => (element.style.display = "none");
showElement = (element) => (element.style.display = "block");

const userConnectButton = document.getElementById("btnConnect");
userConnectButton.onclick = login;

const userProfileButton = document.getElementById("btnUserInfo");

init();

index.html

<!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>Moralis Rarible</title>
  </head>
  <body>
    <div>
      <button id="btnConnect">Connect wallet</button>
      <button id="btnUserInfo">Profile</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>
    <script src="main.js"></script>
  </body>
</html>
1 Like

hideElement and showElement does’t work, too.

Hi @classlacia

I just tested your code and everything is working correctly. Check again that Application ID and SERVER_URL are inscribed in " ". Are you running the site on a live server?

2 Likes

@Yomoo
Thank you for your kindness!
It was a rudimentary mistake, but I solved it by doing a hard reload.

1 Like