I'm getting an obj info like this:
{"github": "https://github.com/Hipo/university-domains-list", "example": "http://universities.hipolabs.com/search?name=middle&country=Turkey", "author": {"name": "hipo", "website": "http://hipolabs.com"}}
api.service.ts, i have the following:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class ApiService {
constructor (private http:HttpClient) { }
getUni(){
return this.http.get('http://universities.hipolabs.com/');
}
}
app.component.ts looks like this:
import { Component, OnInit } from '@angular/core';
import { ApiService } from './api.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
title = 'University API Info - http://universities.hipolabs.com/';
uniData: any ; //= null;
constructor(private api:ApiService) {}
ngOnInit() {
this.api.getUni().subscribe((data)=>{
console.log(data);
this.uniData = data;
}, err=>{
console.log(err);
});
}
}
app.component.html I have the following:
<ul>
<li *ngFor="let uni of uniData">
{{uni.github}}
{{uni.example}}
{{uni.author.name}}
{{uni.author.website}}
</li>
</ul>
I get this error:
ERROR Error: NG02200: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables.
Pls help. thanks