AngularFire httpsCallable Object(...)不是一个函数 [英] AngularFire httpsCallable Object(...) is not a function

查看:71
本文介绍了AngularFire httpsCallable Object(...)不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Ionic 3应用程序中调用httpsCallable函数.我正在尝试关注以下文档: https://firebase.google.com/docs/functions/可调用的

I want to call a httpsCallable function in my Ionic 3 app. I am attempting to follow these docs: https://firebase.google.com/docs/functions/callable

我尝试过:

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

导致的结果:

错误TypeError: WEBPACK_IMPORTED_MODULE_5_firebase_functions .functions不是函数

ERROR TypeError: WEBPACK_IMPORTED_MODULE_5_firebase_functions.functions is not a function

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

I also tried the newly implemented wrapper in angularfire:

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

错误TypeError:Object(...)不是函数

ERROR TypeError: Object(...) is not a function

有人对此有任何经验吗?如果有帮助,这是添加功能的请求. https://github.com/angular/angularfire2/pull/1532

Does anyone have any experience with this yet? Here is the pull request to add the functionality if that helps at all. https://github.com/angular/angularfire2/pull/1532

编辑---

此代码实际上会调用Cloud函数,即使它抛出相同的不是函数"错误:

This code actually calls the Cloud function even though it throws the same 'Not a function' error:

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

即使newGame 是对象而不是函数引用,我也不知道该如何调用该函数.

I'm not sure how else to call the function, even though newGame is an object and not a function reference.

推荐答案

之所以抛出Object(...) is not a function是因为您正在运行rxjs 5,而不是6.

The Object(...) is not a function is thrown because you're running rxjs 5, rather than 6.

如果升级,该功能将按预期执行.

If you upgrade, the function will perform as expected.

有关更改的更多详细信息,请参见 rxjs迁移文档在5到6之间.

See the rxjs migration doc for more details on the changes between 5 and 6.

这篇关于AngularFire httpsCallable Object(...)不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆