I have an Angular 7.x app - I have component that calls a function within a service - this does an GET request to a backend endpoint and returns an array of users;
I am able to see the data within the subscribe (where I have used the console.log) - however I am not able to use the data outside out subscribe() - how do I get access to the data from this.userAccessList
// top of component
public userAccessList: Array<any> = [];
checkAccess(): void {
this.chatMessagesService.getListWithAccessToPage()
.subscribe(json => {
console.log(json); // can see this in the console in the browser
this.userAccessList = json;
});
console.log('userAccessList', this.userAccessList); // appears as an empty array
}