Not showing string showing this weird error? function(){return Fn(“DataSnapshot.val”,0,0,arguments.length),this.node_.val()}

问题: When I try to pull the data this is what happens, I am using child_added to be real-time. I feel like I have to convert it to a string/but I do not know how Sorry for my en...

问题:

When I try to pull the data this is what happens, I am using child_added to be real-time. I feel like I have to convert it to a string/but I do not know how Sorry for my english here is the js file


    $(document).ready(function(){
    var config = {
            apiKey: "AIzaSyB9p1VvVfhnbrcDwUKUuSqw9aQsqnDi4nQ",
            authDomain: "html5project-870df.firebaseapp.com",
            databaseURL: "https://html5project-870df.firebaseio.com",
            projectId: "html5project-870df",
            storageBucket: "html5project-870df.appspot.com",
            messagingSenderId: "54935462861"
          };
    //firebase.initializeApp(config);
    if (!firebase.apps.length) {
        firebase.initializeApp({});
    }
    var database = firebase.database();
    var Rootref = database.ref().child("users");

    Rootref.on("child_added", snap => { 
    var test = "test5765";  

    var name = snap.child("user").val;
    console.log(name);
    $("#read").append("<tr><td>"+name+"</td></tr>");

Here is the result

function(){return Fn("DataSnapshot.val",0,0,arguments.length),this.node_.val()}
function(){return Fn("DataSnapshot.val",0,0,arguments.length),this.node_.val()}
function(){return Fn("DataSnapshot.val",0,0,arguments.length),this.node_.val()}

It posts three times because there are three events Any help is appreciated Here is the github link https://github.com/SaiVeer04/transcriber/blob/master/read.js


回答1:

According to the Firebase documentation snapshot.child(<>).val() is a method not a property.

var name = snap.child("user").val(); // try val() instead of val
console.log(name);
$("#read").append("<tr><td>"+name+"</td></tr>");
  • 发表于 2019-03-28 18:20
  • 阅读 ( 203 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除