Make sure you update your angularfire2 version to RC9 or higher - as this is when the PR was merged.
npm install angularfire2@latest
Add AngularFireFunctions to your providers in your app.module.
import { AngularFireFunctions } from 'angularfire2/functions';
@NgModule({
providers: [
AngularFireFunctions
],
});
Within your Component you can run httpsCallable function from AngularFireFunctions.
constructor(
private afFun: AngularFireFunctions,
) { }
ngOnInit() {
// Angular Fire - Converts Promise to Observable
this.afFun.httpsCallable('myFunction')({ text: 'Some Request Data' })
.pipe(first())
.subscribe(resp => {
console.log({ resp });
}, err => {
console.error({ err });
});
// Convert back to Promise
const respRef = await this.afFun.httpsCallable('myFunction')({ text: 'Some Request Data' })
.toPromise();
console.log({ respRef });
}
A comment in the AngularFire2 repo has asked why the response has been converted to an Observable. The Firebase documentation has the function returning a Promise - so be aware of the inconsistency - it could change in the future.