Firebase.update failed : first argument contains undefined in property

前端 未结 4 1592
无人及你
无人及你 2021-02-04 23:47

I have a simple Firebase function that updates some data. However, the interpreter says that the first argument contains \"undefined\" in property \'users.tester1\'. Can somebod

4条回答
  •  甜味超标
    2021-02-05 00:30

    The underlying Firebase library throws an error when you try to update a property with the value of undefined. It will allow null (and will essentially ignore them).

    You'll need your raw transformer to ensure that it ignores all prototype methods and properties and converts undefined to null or removes any properties with with undefined values altogether.

    var addUser = function(name, edges){
      if(!checkIfUsernameExists(name) && !checkIfNodeNameExists(name) && !checkIfEdgeNameExists(name)){
        var time = Firebase.ServerValue.TIMESTAMP;
    
        //HERE: I think the error is on this line 
        refs.users.update(objify(name, "filler"));
    
        refs.users.child(name).set({
          "id" : time || null,
          "edges" : "filler" || null
        });
        refs.users.child(name).child("edges").update({
          "to" : "filler" || null,
          "from" : "filler" || null
        });
    
        addNode(new Node(name, time, name));
    

提交回复
热议问题