I want to show a list from an API call.
let url = 'api/list';
this.apiService.get<List[]>(url)
.subscribe((response) => {
this.list = response; // response has data
})
console.log(this.list); // no data shown
Because of async behavior the console always shows a blank list. How can I show the list with data outside of the subscribe scope. For clarification I need the list with data in the consoles position. I am familiar with the concept of callback. Do I need to use a callback function here? If yes, how can I achieve that?