How can I get a variable outside of a promise block in a component in Angular 6?
For example
items:string[]=[];
ngOnInit{
const url='SOME URL';
const promise = this.apiService.post(url);
//Response
promise.then(response => {
this.items.push('abc');
this.items.push('def');
});
this.items.forEach(item=>{
alert(item);
});
}
I expect that the application alerts the contents of the items array