AngularFire httpsCallable Object(…) is not a function

左心房为你撑大大i 提交于 2019-12-11 02:58:37

问题


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

I tried:

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

Which resulted in:

ERROR TypeError: WEBPACK_IMPORTED_MODULE_5_firebase_functions.functions is not a function

I also tried the newly implemented wrapper in angularfire:

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

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

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

EDIT---

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

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

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


回答1:


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.

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




回答2:


In your first example make sure you are importing import 'firebase/functions' in the ts file you're calling the function.



来源:https://stackoverflow.com/questions/50431529/angularfire-httpscallable-object-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!