Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting undefined value when I access value of an object

Inside loginUser function, I want to access the value of accessToken which is in side the 'stsTokenManager' but when i try to access this value then i am getting 'undefind' value.

import React, { Component } from 'react';
import {
StyleSheet,
Text, 
View,
Image,
Button,
TouchableWithoutFeedback, StatusBar, TextInput,
SafeAreaView, Keyboard, TouchableOpacity,
KeyboardAvoidingView
} from 'react-native';
import { CheckBox, Item, Label, Input } from 'native-base';
import * as firebase from 'firebase';

const firebaseconfig={
apiKey: " ",
authDomain: " ",
databaseURL: " ",
projectId: " ",
storageBucket: " ",
messagingSenderId: ""
};
firebase.initializeApp(firebaseconfig);

export default class Login extends Component{
// static navigationOptions = {
//     header: null
// }

componentDidMount() {
    firebase.auth().onAuthStateChanged((user) => {
      if (user != null) {
        console.log(user)
      }
    })
}
loginUser = (email, password) => {         
    try {        
      firebase.auth().signInWithEmailAndPassword(email, password )
      .then((response)=>{
        //here i want to access values of 'stsTokenManager'
        console.log(response.user.stsTokenManager);
        }
    }
    catch (error) {
      alert('Check your email or password')
    }
}

Please check my loginUser function because i am able to access email and other think but when i try to access stsTokenManager then i am getting undefind value.And, I am using firebase authentication.

like image 255
surya Avatar asked Dec 11 '22 06:12

surya


1 Answers

response.user.toJSON().stsTokenManager works.

like image 147
Jin Lin Avatar answered Dec 12 '22 20:12

Jin Lin