代码之家  ›  专栏  ›  技术社区  ›  Tristan

AngularFire HttpScalable对象(…)这不是一个函数

  •  2
  • Tristan  · 技术社区  · 7 年前

    我想在我的Ionic 3应用程序中调用HttpScalable函数。我试图遵循以下文件: https://firebase.google.com/docs/functions/callable

    我试过:

    const newGame = (firebase as any).functions().httpsCallable('findCreateGame');
        newGame({}).then(function(result) {
            console.log("In here.");
        });
    

    结果是:

    错误类型错误: WEBPACK_导入的_模块_5_firebase_功能 .函数不是函数

    我还在angularfire中尝试了新实现的包装器:

    const newGame = this.afFunctions.httpsCallable('findCreateGame');
        newGame({}).then(function(result) {
            console.log("In here.");
        });
    

    错误类型错误:对象(…)这不是一个函数

    有人有过这方面的经验吗?下面是添加功能的pull请求(如果有帮助的话)。 https://github.com/angular/angularfire2/pull/1532

    编辑---

    这段代码实际上调用了云函数,尽管它抛出了相同的“nota function”错误:

    const newGame = this.afFunctions.httpsCallable('findCreateGame');
    newGame();
    

    我不知道该如何调用该函数,尽管 newGame 对象而不是函数引用。

    2 回复  |  直到 7 年前
        1
  •  3
  •   James Daniels    7 年前

    这个 Object(...) is not a function 是因为您运行的是rxjs 5,而不是6。

    如果升级,该功能将按预期运行。

    看到了吗 rxjs migration doc 有关5和6之间更改的更多详细信息。

        2
  •  -1
  •   8tomo8    7 年前

    在第一个示例中,确保正在导入 import 'firebase/functions' 在ts文件中调用函数。

    推荐文章