[SOLVED] isAuthenticated not returning properly

this is following the youtube tutorial here: https://www.youtube.com/watch?v=FaTyOg7ickc

it is staying on the authenticate screen and not moving to the isAuthenticated screen. But it does prompt metamask for the signature, and i can sign it. Just doesnt seem to do anything else.

heres the app.js code

import { Button } from "@chakra-ui/button";
import { Container, Heading } from "@chakra-ui/layout";
import { useMoralis } from "react-moralis";


function App() {
  const {authenticate, isAuthenticated, logout } = useMoralis();

  if (isAuthenticated){

    return(
      <Container>

       <Heading>Welcome to MetaWill!</Heading>
       <Button onClick={()=>logout()}>Logout</Button>

      </Container>);
  }    
  



  return (
    <Container>MetaWill
    <Button onClick={()=>authenticate()}>Authenticate</Button></Container>
  );

}
export default App;

heres the index.js code

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
import { MoralisProvider } from "react-moralis";

const theme = extendTheme({
  
  config : {initialColorMode: 'dark'}

  }
  )

  const appId = "wjhh8pvAjKtv7GdOZxBVD4900Amk6varFNU2IuqJ"
  const serverUrl = "https://uxp1jamitjhk.usemoralis.com:2053/server"

ReactDOM.render(
  <React.StrictMode>

<MoralisProvider appId="{appId}" serverUrl="{serverUrl}">
    <ChakraProvider theme = {theme}>
    <App />
    </ChakraProvider>
    </MoralisProvider>
  </React.StrictMode>,
  document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

please help!

edit: also getting this code from the dev console:

POST http://localhost:3000/{serverUrl}/users 404 (Not Found)

also getting this “error” in the console

 Line 15:9:  'appId' is assigned a value but never used      no-unused-vars
  Line 16:9:  'serverUrl' is assigned a value but never used  no-unused-vars

Edit: okay after twidling with it, I got it running. It was making the server details a var that was fucking things up. I got rid of those const’s and just input the data directly, and now its running normally… not sure why though, I THINK I had everything basically the same as the tutorial… such is life.

Here you specified appId and serverUrl as a string. It is a variable so you should remove the quotes around it.

The code should look like this -

<MoralisProvider appId={appId} serverUrl={serverUrl}>
    <ChakraProvider theme = {theme}>
       <App />
    </ChakraProvider>
</MoralisProvider>

This should solve the problem. :slight_smile:

1 Like

Goddammit… always the quotation lol thank you sir.