observable - Angular Cannot read property 'subscribe' of null -


i getting error

cannot read property 'subscribe' of null.

this error happening, called constructor of class:

loaditems() {     this.itemservice.subscribeitems().subscribe(x => {       this.items = x;       console.log(x);     }); } 

it calls services method, issue think. may return null

subscribeitems(): observable<item[]> {     this.session.uid.subscribe(x => {             return this.af.database.list('users/' + x + '/items')             .map(item.fromjsonlist);     });     return null; } 

the session service holds uid updated when user logs in: part works ok.

_uid = new behaviorsubject<string>(''); uid = this._uid.asobservable(); 

try this:

subscribeitems(): observable<item[]> {     return this.session.uid.subscribe(x => {             return this.af.database.list('users/' + x + '/items')             .map(item.fromjsonlist => item.fromjsonlist.json());     });     return null; } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -