3

I have an angular app with the following being imported:

import * as firebase from 'firebase';
import 'firebase/functions';
...
firebase.initializeApp(environment.firebaseConfig);

And when I access the firebase.functions() it shows in my intellisense.

var convertText = firebase.functions().httpsCallable('convertText');

The function convertText exists on my firebase account and works when accessed via http.

When the firebase.functions().httpsCallable() is called I get the follwoing error:

TypeError: firebase.functions is not a function

Here are my libraries.

"@firebase/app": "^0.3.1",
"firebase": "^5.3.1",
"angularfire2": "5.0.0-rc.9",

I followed the following tutorial: Firebase Functions

I know firebase is working as I'm already using fireauth and firestore successfully.

Any help will be appreciated.

3
  • afaik, you have to run functions on the backend via nodejs, its also says that in the docs. Commented Aug 14, 2018 at 12:03
  • Is it firebase.functions().httpsCallable or firebase.functions.httpsCallable? I thought the first one was for Firebase Admin, e.g. admin.functions(). Commented Aug 14, 2018 at 12:22
  • It is for firebase.functions(). The link in my question provides a tutorial on how to access the function from within a (web) application. Commented Aug 14, 2018 at 12:39

1 Answer 1

1

I've just answered this on another SO Question.

As a quick summary;

constructor(
  private afFun: AngularFireFunctions
) { }

ngOnInit() { 
  this.afFun.httpsCallable('myFunction')({ text: 'Some Request Data' })
    .pipe(first())
    .subscribe(resp => {
      console.log({ resp });
    }, err => {
      console.error({ err });
    });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.