Trying to display data in template HTML from a component to service call which calls and returns an API, but I'm getting this error
ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
HTML
<li *ngFor="let item of testing">
<a [routerLink]="[item.url]" >
<span>{{item.name}}</span>
</a>
</li>
Component
testing: any;
this.arsSevice.getMenu()
.subscribe(
result => {
this.testing = result;
console.log('menu',result);
},
error => {
console.log('menu error', error);
}
)
Service:
getMenu() {
return this.http.post(this.menuUrl, JSON.stringify({
"UserID": 61525,
"AppID": 15,
"NavAppID":null,
"AppGroupID": 116,
"SelectedCaseID": 0,
"SelectedRoleID":0
}), httpOptions)
.map((response: Response)=> {
return response;
})
}
Image screenshot of the data
Update
I see a data problem
"menu" has data:
and it what is HERE and NOT working.
the working one is from a different API call Notice that is has
data: Array(16)
How can I fix my data from object to array ?