define class AlphaComponent and implement the OnInit interface
an empty array apiData is declared to store data fetched from an API.
a constructor with a parameter of HelpService is defined;
implements the ngOnInit function which calls getData()
this.getData()
defines the getData function
this.helpService.getPostId().subscribe((jsonData:any) =>{this.apiData = jsonData;
this.helpService.setJasonData(this.apiData);
console.log(this.apiData);
this.apiDataArray(); //RUN THIS FOR LOOP
});
defines the apiDataArray function
loops through the apiData array to log each value
for(let value of this.apiData){
console.log("Data in apiDataArray=>",value);
};
========================================IN Alpha.component.html==========================
<button
class="btn btn-success"
*ngFor="let buttons of
apiData">{{buttons.postId}} //in place of "postId" any desired property value from the
api