I am trying to get information from another component that sends HTTP request with youtube API and I get this problem:
Cannot read property 'subscribe' of undefined
at SafeSubscriber._next (profile.page.ts:20)
this the component code, from here I trying to get the information from the service:
constructor(private db:FirebaseService,private afauth:AuthService) {
this.db.getDataObj("/Profile/" + this.uid).subscribe(res =>{
this.profileInfo= res;
this.afauth.getYoutubeData(res.channel).subscribe(data =>{
console.log(data);
})
})}
this the code of the function of the service that send the http request:
getYoutubeData(ch):any{
let m="https://www.googleapis.com/youtube/v3/channels?
part=snippet%2CcontentDetails%2Cstatistics&id=" + ch + "&key=" + api ;
this.http.get(m).subscribe(data =>
{
this.youtubeObj=data.items["0"].statistics;
return this.youtubeObj;
})
}