【问题标题】:FIREBASE WARNING: TypeError: Cannot read property 'then' of undefinedFIREBASE 警告:TypeError:无法读取未定义的属性“then”
【发布时间】:2018-04-27 04:14:36
【问题描述】:

根据文档,大多数 firebase-database 动词都会返回 Promise。但是我不能在.once().remove().set() 上致电.then()

这是我正在使用的版本:

4.12.0

这是错误

 FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'then' of undefined

这是具体的例子:

   collab_ref = new Firebase(FBURL + 'collaboration_songs').child(collaboration_id);
   return collab_ref.remove().then(function(){
          return cb();
        });

【问题讨论】:

    标签: javascript firebase firebase-realtime-database


    【解决方案1】:

    根据文档,初始化 3.x 及更高版本的 firebase 应用程序的正确方法是这种方式。

    初始化

    var config = {
      apiKey: "apiKey",
      authDomain: "projectId.firebaseapp.com",
      databaseURL: "https://databaseName.firebaseio.com"
    };
    
    firebase.initializeApp(config);
    

    玩得开心

    var niceNode = firebase.database().ref().child('collaboration_songs')
    .remove()
    .then(resolve => { return ':)'}, (reject) => return ':(');
    

    https://firebase.google.com/docs/database/web/start

    【讨论】:

      猜你喜欢
      • 2019-08-19
      • 2014-09-07
      • 1970-01-01
      • 1970-01-01
      • 2018-10-19
      • 2014-11-26
      • 2014-11-29
      • 2016-09-20
      相关资源
      最近更新 更多