Get Current User method broken for JS SDK

Currently having an issue with Backendless getCurrentUser method. When I first log in the getCurrentUser method works just fine. But once I refresh the web page for our app the getCurrentUser method:
Backendless.UserService.getCurrentUser()
.then(currentUser => {
console.log(currentUser)
})
.catch(error => {
console.error(error)
})

Has the following errors:
image

Also to note: When I clear my browser data and cookies, I am able to login to the web page and use the getCurrentUser function again, until I refresh the page and then it shows the same errors again.

Any help with this issue would be greatly appreciated!

Hello @David_Hasler

Could you show your login logic?
Did you use stayLoggedIn param?

Regards, Dima

Hey @Dima

Yes we used the stayLoggedIn param and set it to true.

Here is our login function:

login: (identity:string, password:string, stayLoggedIn:boolean|undefined = undefined) => {
return Backendless.UserService.login(identity, password, stayLoggedIn)
.then(async (user) => {
}

      return currentUser.value = user as User;
    });
},

And here is the method invocation:
const email = loginAttempt.email;
const password = loginAttempt.password;
userStore.login(email, password, true)
.then(loggedInUser => router.push(“/actions”))
.catch(err => errorMessage.value = err)

Hello David,

we tried to reproduce your case, but no luck.
Could you please create a small reproducible demo/sample so we could look into it?
Without it, it’s hard to say what’s happening, because just by looking at your code, it is fine, and refreshing a browser page should not log out the user since you’re using stayLoggedIn param.

Hey @stanislaw.grin

Thank you so much for looking into this!
Unfortunately it was old cloudless code on our end that is causing the issue. We weren’t able to login because of the issue and because it was happening on the getCurrentUser function we thought that may be the issue. But it was a column on the users table called trialExpired which we set up and most of our accounts happened to expire at the same time! We are working on fixing the code on our end now that we have found the issue.

Thanks again!
David Hasler