Moralis Session time out

Hi There!
How to determine the session is time out, some time we get this error.

Because of that, the client-side app is breaking, we have to manually refresh it to work.

@neil
On the https://xxxxxx.moralis.io:2083/apps/moralisDashboard/browser/_Session you can find the end date of the user sessions.

Take a look at Sessions

Are you sure that problem/error is related to sessions?

@taha This will help, Thanks

@cryptokid. yes sessions

were you able to fix those errors?

Still have not started to fix it, but we think this will help.

function handleMoralisError(err) {
  switch (err.code) {
    case Moralis.Error.INVALID_SESSION_TOKEN:
      Moralis.User.logOut();
      // If web browser, render a log in screen
      // If Express.js, redirect the user to the log in route
      break;

    // Other Moralis API errors that you want to explicitly handle
  }
}

// For each API request, call the global error handler
query.find().then(function() {
  // do stuff
}, function(err) {
  handleMoralisError(err);
});

also, this is working

if (error) {
        return <MoralisError error={error} />; // our error componet
    }
1 Like