I'm currently trying to make a function where it loops and by using .subscribe I'm getting an array object each time so that later on I can push the data inside an another array. The loop works but the problem is that the results is not what I want because the .subscribe part is printing the first array and then for the rest it's giving me null arrays whereas it suppose to print 20x the same array. I currently started experimenting with angular and to my knowledge of other languages I don't think that it's working good by first printing "Test"x20 and after goes inside the subscribe and printing.
Function:
testingFunction()
{
let i: number = 0;
while(i < 20){
console.log("Test");
this.testService.getAll().subscribe((object: any[]) => {
console.log(object);
})
i++;
}
}