[英]firebase: don't get data from realtime database
I don't get data from realtime database, but load is perfect.我没有从实时数据库中获取数据,但负载很完美。 how fix it?
如何修复它?
const dbRef = database.ref();
var data;
dbRef.child("playlists").child(1).get().then((snapshot) => {
data = snapshot.val();
}).catch((error) => {
console.error(error);
});
There isn't anything wrong in the code but could you try running it this way?代码没有任何问题,但是您可以尝试以这种方式运行它吗?
firebase.database().ref("playlists/1").once("value").then((snapshot) => {
console.log(snapshot.val());
}).catch(e => {
console.log(e);
})
Just in case you've share a small part of your code, then there is a typo in the word 'description'.以防万一您共享了一小部分代码,那么“描述”一词中就会出现拼写错误。 You might want to check if that's the same in your code else it'll log undefined.
您可能想检查代码中是否相同,否则它将记录未定义。
Let me know if issue still persists.让我知道问题是否仍然存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.