Search code examples
angulartypescriptfirebaseobservableangularfire

AngularFire firebase cloud function return value problem


I have a problem with AngularFire, because in their github (Documentation) it says it returns an Observable.

This is a new account on stackoverflow so i cant embedd the image here.

code problem

but the thing is that i cant subscribe to the Observable.

My guess is that it has to do something with the

(data: any) => Observable<any>;

because when i try to typedef the httpCallReleaseUser variable to an Observable. I get an error that tells me that it doesnt have the subscribe + some other methods.

now with type definition

if thats the problem

What is the difference between

Observable<any>

and

(data: any) => Observable<any>;

Solution

  • This difference between Observable and () => Observable is that the latter is a function that outputs an Observable.

    AngularFireFunctions has the signature httpsCallable(name:string) => (data:any) => Observable<any>, meaning you have to call it twice, first with the name of your function, and then again with the data you want to pass to the function.

    functions.httpsCallable('fn-name')({ ... your data here or empty })