我使用firebase啓動我的web應用程序,然後向數據庫添加新數據:{'title':'hello world!'}。然後我試圖得到這樣的數據:database.ref().child('title')
和我奇怪的物體: 從firebase中獲取數據不起作用
我的代碼:
export class App extends Component {
constructor(props) {
super(props);
// Initialize Firebase
var config = {
apiKey: "&&&&&&&dbBJY_ie3CbXtnL6M6QBEL2JqWI",
authDomain: "&&&&&&&.firebaseapp.com",
databaseURL: "&&&&&test-61197.firebaseio.com",
storageBucket: "test-&&&&.appspot.com",
messagingSenderId: "7&&&1193299"
};
firebase.initializeApp(config);
// Get a reference to the database service
var database = firebase.database();
console.log(database.ref().child('title'));
}
login() {
console.log('login');
// Log the user in via Twitter
}
render() {
return (
<View style={styles.container}>
<Touchable style={styles.loginBtn} onPress={ this.login }>
<Text style={styles.loginBtnText}>login</Text>
</Touchable>
</View>
);
}
}
如何得到我的數據? Firebase版本:3.4.0
你能告訴我們你的代碼嗎?我的猜測是你必須在該對象上調用'.val()'。 – yihangho
是的,這是我的代碼:[jsfiddle link](https://jsfiddle.net/1mxc9zsg/) – Slava