sur*_*rya 3 javascript json firebase react-native firebase-authentication
在 loginUser 函数中,我想访问 'stsTokenManager' 中的 accessToken 的值,但是当我尝试访问该值时,我得到了 'undefind' 值。
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')
}
}
Run Code Online (Sandbox Code Playgroud)
请检查我的 loginUser 函数,因为我可以访问电子邮件和其他想法,但是当我尝试访问 stsTokenManager 时,我得到了 undefind 值。而且,我正在使用 firebase 身份验证。