Having problems with Ionic build and observable


#1

Sometimes when I’m building my app it randomly throws and error. Even though I have not made any changes to this page.

profileData: Observable ;

this.profileData = this.afDatabse.object(/profile/${data.uid}).valueChanges();


#2

You have not specified the type of Observable. Observables use generics. Try using this:

profileData: Observable<Profile>;

#3

Sorry, my bad with copy pasting, I have type it’s not allowed in html version on the post


#4

FYI: Use the </> button above the input field to format your code, command line output or error message (select the text first, then click the button or wrap it in ``` manually). This will make sure your text is readable and if it recognizes the programming language it also automatically adds code syntax highlighting.


#5

Then maybe your return value is not from type Profile. Does the object() fn or valueChanges() fn use generics? It adding generics to one of these doesn’t work, you could try to cast your return value to any:

this.profileData = <any> this.afDatabse.object( ...

And is afDatabse correct or is it called afDatabase?