Support Topics Documentation Slack YouTube Blog

backendless.UserService.login() user is logged in but no user object is returned

(MZ B) #1

I am using the javascript sdk in a react-native app. In debug mode, everything is fine but in release mode, I can see in the panel that the user is successfully logged in but no user object is returned to me so the view never get updated.
Any help or advice is appreciated, thanks.
Here is my code:

import {_ERR, _LOGIN} from "./types";
import Backendless from "backendless";
import {AsyncStorage} from "react-native";
export const LoginUserAction = ({email, password, navigation}) => {
 return (dispatch) => {
 Backendless.UserService.login(email, password, true)
 .then(user => {
 const userData = {
 token: Backendless.LocalCache.get('user-token'),
 id: Backendless.LocalCache.get('current-user-id'),
 ownerId: user.ownerId
 dispatch({type: _LOGIN, payload: user.toString()});
 AsyncStorage.setItem('user', JSON.stringify(userData),(res)=>{
 }).catch(error =>{
 dispatch({type: _ERR, payload: error.message});
 }).catch(error => {
 dispatch({type: _ERR, payload: error.message});

(Sergey Chupov) #2


Please be more specific, what do you mean by “no user object is returned”? Have you inspected what the “user” variable contains in ‘then’ after .login() call?

(MZ B) #3

Yes, I have. In debug mode, the user object is returned in ‘then’. But in release mode ‘then’ part never runs. I can see in the panel that the user is successfully logged in but here in my app no data, no ‘then’ part, nothing! It only happens in release mode and I’m pretty sure the code is fine. I think something happens when I run ‘gradlew assembleRelease’.

(Vladimir Upirov) #4


  1. Are your sure that this line works as correctly
dispatch({ type: _LOGIN, payload: user.toString() });

I think user.toString() will return “[object Object]”

  1. In ReactNative docs I see that AsyncStorage.setItem returns a Promise if callback is not passed, so could you take a look on this:
AsyncStorage.setItem('user', JSON.stringify(userData))
.then(res => {
.catch(error => {
dispatch({ type: _ERR, payload: error.message });

(MZ B) #5

Apart from the user.toString() ,which I added to my code to see if i see anything even [object Object] in my released app, the code works fine just as is in debug mode. If it was wrong, It wouldn’t be working in debug mode. I only have this problem in release mode. No data actually returns from Backendless to be dispatched in my app. I have been struggling with this issue for more than 2 weeks now and believe me I have tried every possible solution I could think of.

(Vladimir Upirov) #6

ok, could you please create a simple project with this problem and send it to

and we will try to reproduce the problem

you can generate it via Console</img>



(MZ B) #7

Thank you Vladimir. I downloaded the project template and realized that it’s using react native 0.42 . My project dependencies are as follows:“dependencies”: {
“backendless”: “^4.3.0”,
“react”: “^16.0.0”,
“react-native”: “^0.51.0”,
“react-navigation”: “^1.0.0-beta.15”,
“react-redux”: “^5.0.6”,
“redux”: “^3.7.2”,
“redux-thunk”: “^2.2.0”
“devDependencies”: {},
“jest”: {
“preset”: “react-native”


Let me try again with Backendless template and see if I bump into problem again.

Thank you again for your time and patience.

(MZ B) #8

For anyone that might come up with the same issue, I also tried the Backendless template but more problems came up due to old version of react native. At the end I used the Rest API (and not the JS SDK) and used fetch API to get data and the problem is solved now.