Reputation: 11
I'm trying to run a chat app using ionic and I'm getting this message
[19:55:51] typescript: src/pages/chat/chat.ts, line: 26
Property 'subscribe' does not exist on type 'AngularFireList<{}>'.
L25: this.username = this.navParams.get('username');
L26: this._chatSubscription = this.db.list('/chat').subscribe( data => {
L27: this.messages = data;
[19:55:51] typescript: src/pages/chat/chat.ts, line: 37
Property 'catch' does not exist on type 'PromiseLike<void>'.
L36: // message is sent
L37: }).catch( () => {
L38: // some error. maybe firebase is unreachable
can anybody help me?
Upvotes: 0
Views: 3074
Reputation: 520
You need to specify valueChanges() or snapshotChanges() before you subscribe.
valueChanges() Returns an Observable of data as a synchronized array of JSON objects. All Snapshot metadata is stripped and just the method provides only the data.
snapshotChanges() Returns an Observable of data as a synchronized array of AngularFireAction[].
You can read more about retrieving data here
So your code should look like this:
this.db.list('chat').valueChanges().subscribe(data => {
this.messages = data;
});
Upvotes: 3