I want to get data out of observable, i understand that observable is async so it is not making any sense, but is there any way(workaround to achieve it)? Or maybe making the observable synchronous?
My code:
namesList: string[] = [];
ngOnInit() {
this.httpService.list(this.env.someurl).subscribe((items) => {
this.namesList= items.map( item => item.name)
console.log(this.nameList) //has data
});
console.log(this.nameList) //empty array
}