[SOLVED] Console is not a function?

Hello, I am new to this community. I have attempted to watch some tutorials on getting started with Moralis, but it appears the code has changed. The tutorial on the website didn’t work. I tried a video tutorial which led me to the vanilla boilerplate, but now there is an HTML file and a JS file. I copied the boilerplate from both and put in my server URL and app ID and tried to run it on localhost. When I do that, the button doesn’t do anything and the following error is displayed in the console:

main.js:16 Uncaught (in promise) TypeError: console is not a function
at main.js:16
at async HTMLButtonElement.login (main.js:10)

As is, it appears the code doesn’t work as described in the tutorial, but I’m not sure why my browser can’t access the console through the code. Can anybody help me? (By the way, I hope this is in the right place. I figured it qualified as a technical issue considering you can’t follow the tutorial provided after the update.)

Hi, this is the right place.

What is the boilerplate that you use? it may be an old version, but still, you shouldn’t get that error with console. Can you add here your html and javascript code that gives you that error?

You can read here about how to post code: READ BEFORE POSTING - How to post code in the forum

Hey, thanks for the response. Sorry it took me so long to get back to this project. I’ve been pretty busy. Update: The boilerplate has been updated since I made this post. Using the new boilerplate has helped bring some clarity to the issue due to it providing different error messages. Now it’s telling me that my browser is not Ethereum enabled, but I have the Metamask extension installed and even tried to log into it first just to get the same error message.

Here is the boilerplate I’m using for index:

<!DOCTYPE html>
    <title>Vanilla Boilerplate</title>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>

    <button id="btn-login">Moralis Metamask Login</button>
    <button id="btn-logout">Logout</button>
    <script type="text/javascript" src="./main.js"></script>

And main:

const serverUrl = ""; //This field is not really empty. I just removed the value.
const appId = ""; //Same story here.
Moralis.start({ serverUrl, appId });

/** Add from here down */
async function login() {
  let user = Moralis.User.current();
  if (!user) {
   try {
      user = await Moralis.authenticate({ signingMessage: "Hello World!" })
   } catch(error) {

async function logOut() {
  await Moralis.User.logOut();
  console.log("logged out");

document.getElementById("btn-login").onclick = login;
document.getElementById("btn-logout").onclick = logOut;

And here are the details of the error message I get in my browser now:

Error: Non ethereum enabled browser
    at moralis.js:4629
    at tryCatch (moralis.js:28071)
    at Generator.invoke [as _invoke] (moralis.js:28301)
    at Generator.next (moralis.js:28126)
    at asyncGeneratorStep (moralis.js:27580)
    at _next (moralis.js:27602)
    at moralis.js:27609
    at new Promise (<anonymous>)
    at new Wrapper (moralis.js:32483)
    at moralis.js:27598

This pops up at line 55 (console.log(error)) after clicking the login button.

Usually you get this error if you didn’t start a HTTP server and you opened directly a local file in your browser.

Oh yeah I forgot about that. So I’ve tried 3 different live server extensions for visual studio code, but I can’t get any of them to work. 1 of them is broken, 1 of them doesn’t seem to do anything and doesn’t change anything in my browser, and the other one runs the code without any errors (now for some reason), but nothing happens when I click the button in the live server preview.

you can start a http server with python too (after you install python): python -m http.server 81 for example for port 81

1 Like

Awesome! I was able to figure out how to do that. That worked and I was able to log in and get the Hello World message. Now the only thing it doesn’t like is that I don’t have favicon.ico. But it’s working. I’m still near the beginning of the tutorial and I can keep going now. Thank you!


Hey guys! I have the same issue. For the record: http-server has been started. After logging in I am pressing the Donate button and it says

favicon.ico:1          GET 404 (Not Found)
(index):26 ParseUser {id: 'dPl2d0SdlIYYCql5CNpGARAb', _objCount: 0, className: '_User'}
(index):27 0xd2dc28f65c76510a4a930d28664a60828c4cf64e
(index):51 Uncaught (in promise) TypeError: Moralis.User.executeFunction is not a function
    at HTMLButtonElement.donate ((index):51:32)"

You can create a new thread. That executeFunction is not on user class