如果有任何错误,firebase回调函数不会被调用

问题描述:

我试图使用firebase-admin模块来设置我的数据在云功能。我添加了回调函数来处理错误。但是,如果属性值中的任何一个“未定义”,它会抛出日志如果有任何错误,firebase回调函数不会被调用

Error : Firebase.set failed: First argument contains undefined in property 

我期待的是火力应该叫我的回调函数的错误。我应该使用try-catch来处理这种情况吗?

return admin.database().ref('mypath').set({ 
prop1 : value1, 
prop2 : value2 
}, function (error){ 
     console.log('got the error ', error); 
     if(error){ 
      setErroneousRecord(row, index); 
     } else { 
      successfulRecords++; 
     } 
    }); 
+0

向我们显示您的代码。 –

+0

@camden_kid添加了代码 –

好像要么value1value2undefined,这是不允许的,在客户端/ SDK检测和拒绝写入。

Firebase错误回调仅针对服务器端故障调用,因此当Firebase安全规则拒绝写入操作时。