Sorry for that bad title. I am getting data from api with httpclient and when I console.log that data inside of a subscribe everything works fine, but when I do: this.launches = data and then try to console.log that what I see is "Undefined" in the console
launches:LaunchRootObject;
showLaunches(){
this.client.GetAllLauches().subscribe((data:LaunchRootObject) =>{
console.log(data); //this is working
this.launches = data;
});
}
ngOnInit(): void {
this.showLaunches();
console.log(this.launches) //this shows "Undefined"
}
This is a part of a http service:
GetAllLauches(){
return this.http.get<LaunchRootObject>(this.base_url + 'launch');
}