title: Angular 8 error '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays
body: <p>I'm new to Angular 8 and I am using the following structure to fetch data from http get and I am trying to iterate data using *ngFor. Unfortunately, I am getting the following error.</p>
  
  <p>How to fix the error? Thank you in advance 
  <code>
  '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
  </code>
  student model</p>
  
  <pre><code>export class Student {
      Name: string;
      Sport: string;
  
  }
  </code></pre>
  
  <p>student.service.ts</p>
  
  <pre><code>    public getData(path: string): Observable&lt;Student[]&gt; {
          return this.http.get&lt;Student[]&gt;(this.mainUrl + path).pipe(
              tap(_ =&gt; console.log('fetched data'))
          );
      }
  </code></pre>
  
  <p>student.component.ts</p>
  
  <pre><code>import { Observable, of } from 'rxjs'; 
  import { Student } from 'src/app/models/student';
  import { HttpService } from 'src/services/http.service';
  import { StudentService } from './student.service';
  
  
  @Component ({
      selector: 'student',
      templateUrl: 'student.component.html',
      styleUrls: ['student.component.css']
  })
  
  export class StudentComponent implements OnInit {
      students: Student[];
  
      constructor(
          private studentService: StudentService
          ) {
      }
  
      getStudents(): void {
  
          let ppp = this.studentService.getData("get_students");
          this.studentService.getData("get_students").subscribe(
              students =&gt; { this.students = students }
              // students =&gt; {console.log(this.students)}
          );
          console.log(this.students); // prints undefined
      }
  
  
      ngOnInit() {
          this.getStudents();
  
      }   
  }
  </code></pre>
  
  <p>student.component.html</p>
  
  <pre><code>&lt;li *ngFor="let p of students"&gt;
  
    &lt;div&gt;hello&lt;/div&gt;
  &lt;/li&gt; 
  </code></pre>