Quins
Quins

Reputation: 813

Firebase functions in angular app not working

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.

Upvotes: 3

Views: 1019

Answers (1)

sketchthat
sketchthat

Reputation: 2688

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 });
    });
}

Upvotes: 1

Related Questions