Cannot find a differ supporting object ‘[object Object]’ of type ‘object’. NgFor only supports binding to Iterables such as Arrays

Photo by Lautaro Andreani on Unsplash

I looked at similar questions, but none of them helped me. I am going to receive an object like the following:

[
{
"id": 1,
"name": "Safa",
"email": "neerupeeru@mail.ee",
"purpose": "thesis",
"programme": "Software Engineering",
"year": 2016,
"language": "Estonian",
"comments": "In need of correcting a dangling participle.",
"status": "RECEIVED"
},
{
"id": 2,
"name": "Safa",
"email": "neerupeeru@mail.ee",
"purpose": "thesis",
"programme": "Software Engineering",
"year": 2016,
"language": "Estonian",
"comments": "In need of correcting a dangling participle.",
"status": "RECEIVED"
},
{
"id": 3,
"name": "Salman",
"email": "neerupeeru@mail.ee",
"purpose": "thesis",
"programme": "Software Engineering",
"year": 2016,
"language": "Estonian",
"comments": "In need of correcting a dangling participle.",
"status": "RECEIVED"
}
]

and here is my http service to receive it:

getRequest(){
return this._http.get("http://consultationwebserver.herokuapp.com/requests").map(res => res.json());
}

and finally, in the i called the service in this way:

requests;
constructor(private _http:requestService){}
ngOnInit(){
this.requests=this._http.getRequest().subscribe(res=>this.requests=res);
}

Unfortunately, when the page loads it complains with:

Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

So, what is going wrong with this code?

Solution for the above problem is..

There you don’t need to use this.requests= when you are making get call(then requests will have observable subscription). You will get a response in observable success so setting requests value in success make sense(which you are already doing).

this._http.getRequest().subscribe(res=>this.requests=res);

Check more solutions on the same problem at syntaxfix.com

--

--

--

Curated Solutions On Popular Questions — On All Programming Languages, Cloud Computing, Tools etc

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

About javascript array

Most Commonly Used String Methods in JavaScript

Web Development Patterns of 2018 and 2019 which Changed

How to use React in your Ruby on Rails app 2022

Constitutional Law

Follow me on Soundcloud

Everything One Can Ask You About JavaScript Arrow Functions in 2021

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
SyntaxFix

SyntaxFix

Curated Solutions On Popular Questions — On All Programming Languages, Cloud Computing, Tools etc

More from Medium

How to add Bootstrap to the Angular Project

Knowing the differences between Angular vs Angular JS

I have created component server display.

Implementing ApexCharts in Angular