Cannot find a differ supporting object angular 7












0















Hi I am using Angular 7



I created service user-report.service.ts
for get method is not printing in browser



getReport() {
/*this.http.get(`${this.apiUrl}/report`)
.subscribe(res => console.log(res._body));*/
return this
.http
.get(`${this.apiUrl}/report`);
}


user-report.component.ts



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = data;
console.log(data);
});
}


template



<table class="table table-hover">
<thead>
<tr>
<td>User Name</td>
<td>Created Date</td>
<td>Updated Date</td>
<td>Time</td>
<td>Status</td>
</tr>
</thead>

<tbody>
<tr *ngFor="let report of reports">
<td>{{ report.username }}</td>
<td>{{ report.created_date }}</td>
<td>{{ report.updated_date }}</td>
<td>{{ report.time }}</td>
<td>{{ report.status }}</td>

</tr>
</tbody>
</table>


but i got a error like this



ERROR Error: Cannot find a differ supporting object 'Response with status: 200 OK for URL: http://localhost:3000/report' of type 'object'. NgFor only supports binding to Iterables such as Arrays.



i don't know what is the problem










share|improve this question

























  • Check this.userReport.getReport()… its not returning an array - is it returning a single report?. Try testing the URL in a browser. FYI, just because you cast the object to an array, does not make it so.

    – pixelbits
    Nov 14 '18 at 13:53













  • NgFor only supports binding to Iterables such as Arrays.

    – Jai
    Nov 14 '18 at 13:56











  • What do you receive in the data? Is it an array or object?

    – Surjeet Bhadauriya
    Nov 14 '18 at 13:58











  • my data Response {headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body}

    – Learning
    Nov 14 '18 at 14:35


















0















Hi I am using Angular 7



I created service user-report.service.ts
for get method is not printing in browser



getReport() {
/*this.http.get(`${this.apiUrl}/report`)
.subscribe(res => console.log(res._body));*/
return this
.http
.get(`${this.apiUrl}/report`);
}


user-report.component.ts



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = data;
console.log(data);
});
}


template



<table class="table table-hover">
<thead>
<tr>
<td>User Name</td>
<td>Created Date</td>
<td>Updated Date</td>
<td>Time</td>
<td>Status</td>
</tr>
</thead>

<tbody>
<tr *ngFor="let report of reports">
<td>{{ report.username }}</td>
<td>{{ report.created_date }}</td>
<td>{{ report.updated_date }}</td>
<td>{{ report.time }}</td>
<td>{{ report.status }}</td>

</tr>
</tbody>
</table>


but i got a error like this



ERROR Error: Cannot find a differ supporting object 'Response with status: 200 OK for URL: http://localhost:3000/report' of type 'object'. NgFor only supports binding to Iterables such as Arrays.



i don't know what is the problem










share|improve this question

























  • Check this.userReport.getReport()… its not returning an array - is it returning a single report?. Try testing the URL in a browser. FYI, just because you cast the object to an array, does not make it so.

    – pixelbits
    Nov 14 '18 at 13:53













  • NgFor only supports binding to Iterables such as Arrays.

    – Jai
    Nov 14 '18 at 13:56











  • What do you receive in the data? Is it an array or object?

    – Surjeet Bhadauriya
    Nov 14 '18 at 13:58











  • my data Response {headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body}

    – Learning
    Nov 14 '18 at 14:35
















0












0








0








Hi I am using Angular 7



I created service user-report.service.ts
for get method is not printing in browser



getReport() {
/*this.http.get(`${this.apiUrl}/report`)
.subscribe(res => console.log(res._body));*/
return this
.http
.get(`${this.apiUrl}/report`);
}


user-report.component.ts



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = data;
console.log(data);
});
}


template



<table class="table table-hover">
<thead>
<tr>
<td>User Name</td>
<td>Created Date</td>
<td>Updated Date</td>
<td>Time</td>
<td>Status</td>
</tr>
</thead>

<tbody>
<tr *ngFor="let report of reports">
<td>{{ report.username }}</td>
<td>{{ report.created_date }}</td>
<td>{{ report.updated_date }}</td>
<td>{{ report.time }}</td>
<td>{{ report.status }}</td>

</tr>
</tbody>
</table>


but i got a error like this



ERROR Error: Cannot find a differ supporting object 'Response with status: 200 OK for URL: http://localhost:3000/report' of type 'object'. NgFor only supports binding to Iterables such as Arrays.



i don't know what is the problem










share|improve this question
















Hi I am using Angular 7



I created service user-report.service.ts
for get method is not printing in browser



getReport() {
/*this.http.get(`${this.apiUrl}/report`)
.subscribe(res => console.log(res._body));*/
return this
.http
.get(`${this.apiUrl}/report`);
}


user-report.component.ts



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = data;
console.log(data);
});
}


template



<table class="table table-hover">
<thead>
<tr>
<td>User Name</td>
<td>Created Date</td>
<td>Updated Date</td>
<td>Time</td>
<td>Status</td>
</tr>
</thead>

<tbody>
<tr *ngFor="let report of reports">
<td>{{ report.username }}</td>
<td>{{ report.created_date }}</td>
<td>{{ report.updated_date }}</td>
<td>{{ report.time }}</td>
<td>{{ report.status }}</td>

</tr>
</tbody>
</table>


but i got a error like this



ERROR Error: Cannot find a differ supporting object 'Response with status: 200 OK for URL: http://localhost:3000/report' of type 'object'. NgFor only supports binding to Iterables such as Arrays.



i don't know what is the problem







angular angular7






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 11:12









Goncalo Peres

1,4691619




1,4691619










asked Nov 14 '18 at 13:50









LearningLearning

307




307













  • Check this.userReport.getReport()… its not returning an array - is it returning a single report?. Try testing the URL in a browser. FYI, just because you cast the object to an array, does not make it so.

    – pixelbits
    Nov 14 '18 at 13:53













  • NgFor only supports binding to Iterables such as Arrays.

    – Jai
    Nov 14 '18 at 13:56











  • What do you receive in the data? Is it an array or object?

    – Surjeet Bhadauriya
    Nov 14 '18 at 13:58











  • my data Response {headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body}

    – Learning
    Nov 14 '18 at 14:35





















  • Check this.userReport.getReport()… its not returning an array - is it returning a single report?. Try testing the URL in a browser. FYI, just because you cast the object to an array, does not make it so.

    – pixelbits
    Nov 14 '18 at 13:53













  • NgFor only supports binding to Iterables such as Arrays.

    – Jai
    Nov 14 '18 at 13:56











  • What do you receive in the data? Is it an array or object?

    – Surjeet Bhadauriya
    Nov 14 '18 at 13:58











  • my data Response {headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body}

    – Learning
    Nov 14 '18 at 14:35



















Check this.userReport.getReport()… its not returning an array - is it returning a single report?. Try testing the URL in a browser. FYI, just because you cast the object to an array, does not make it so.

– pixelbits
Nov 14 '18 at 13:53







Check this.userReport.getReport()… its not returning an array - is it returning a single report?. Try testing the URL in a browser. FYI, just because you cast the object to an array, does not make it so.

– pixelbits
Nov 14 '18 at 13:53















NgFor only supports binding to Iterables such as Arrays.

– Jai
Nov 14 '18 at 13:56





NgFor only supports binding to Iterables such as Arrays.

– Jai
Nov 14 '18 at 13:56













What do you receive in the data? Is it an array or object?

– Surjeet Bhadauriya
Nov 14 '18 at 13:58





What do you receive in the data? Is it an array or object?

– Surjeet Bhadauriya
Nov 14 '18 at 13:58













my data Response {headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body}

– Learning
Nov 14 '18 at 14:35







my data Response {headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body}

– Learning
Nov 14 '18 at 14:35














1 Answer
1






active

oldest

votes


















0














Simple fix to convert your single report to an array:



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = [data];
console.log(data);
});
}





share|improve this answer
























  • this.reports = [data._body]; it work correctly but in table noting is printed

    – Learning
    Nov 14 '18 at 14:05











  • why data._body? is _body a property you're returning in your json?

    – pixelbits
    Nov 14 '18 at 14:09











  • headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

    – Learning
    Nov 14 '18 at 14:16











  • Looking at your json, _body is already an array. Try this.reports = data._body;

    – pixelbits
    Nov 14 '18 at 14:19













  • i think loop is a problem if i print this {{reports}} it print but ngFor not working

    – Learning
    Nov 14 '18 at 14:22











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301802%2fcannot-find-a-differ-supporting-object-angular-7%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Simple fix to convert your single report to an array:



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = [data];
console.log(data);
});
}





share|improve this answer
























  • this.reports = [data._body]; it work correctly but in table noting is printed

    – Learning
    Nov 14 '18 at 14:05











  • why data._body? is _body a property you're returning in your json?

    – pixelbits
    Nov 14 '18 at 14:09











  • headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

    – Learning
    Nov 14 '18 at 14:16











  • Looking at your json, _body is already an array. Try this.reports = data._body;

    – pixelbits
    Nov 14 '18 at 14:19













  • i think loop is a problem if i print this {{reports}} it print but ngFor not working

    – Learning
    Nov 14 '18 at 14:22
















0














Simple fix to convert your single report to an array:



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = [data];
console.log(data);
});
}





share|improve this answer
























  • this.reports = [data._body]; it work correctly but in table noting is printed

    – Learning
    Nov 14 '18 at 14:05











  • why data._body? is _body a property you're returning in your json?

    – pixelbits
    Nov 14 '18 at 14:09











  • headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

    – Learning
    Nov 14 '18 at 14:16











  • Looking at your json, _body is already an array. Try this.reports = data._body;

    – pixelbits
    Nov 14 '18 at 14:19













  • i think loop is a problem if i print this {{reports}} it print but ngFor not working

    – Learning
    Nov 14 '18 at 14:22














0












0








0







Simple fix to convert your single report to an array:



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = [data];
console.log(data);
});
}





share|improve this answer













Simple fix to convert your single report to an array:



getReport() {
this.userReport.getReport()
.subscribe((data: UserReport) => {
this.reports = [data];
console.log(data);
});
}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 14 '18 at 13:56









pixelbitspixelbits

40.2k1065102




40.2k1065102













  • this.reports = [data._body]; it work correctly but in table noting is printed

    – Learning
    Nov 14 '18 at 14:05











  • why data._body? is _body a property you're returning in your json?

    – pixelbits
    Nov 14 '18 at 14:09











  • headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

    – Learning
    Nov 14 '18 at 14:16











  • Looking at your json, _body is already an array. Try this.reports = data._body;

    – pixelbits
    Nov 14 '18 at 14:19













  • i think loop is a problem if i print this {{reports}} it print but ngFor not working

    – Learning
    Nov 14 '18 at 14:22



















  • this.reports = [data._body]; it work correctly but in table noting is printed

    – Learning
    Nov 14 '18 at 14:05











  • why data._body? is _body a property you're returning in your json?

    – pixelbits
    Nov 14 '18 at 14:09











  • headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

    – Learning
    Nov 14 '18 at 14:16











  • Looking at your json, _body is already an array. Try this.reports = data._body;

    – pixelbits
    Nov 14 '18 at 14:19













  • i think loop is a problem if i print this {{reports}} it print but ngFor not working

    – Learning
    Nov 14 '18 at 14:22

















this.reports = [data._body]; it work correctly but in table noting is printed

– Learning
Nov 14 '18 at 14:05





this.reports = [data._body]; it work correctly but in table noting is printed

– Learning
Nov 14 '18 at 14:05













why data._body? is _body a property you're returning in your json?

– pixelbits
Nov 14 '18 at 14:09





why data._body? is _body a property you're returning in your json?

– pixelbits
Nov 14 '18 at 14:09













headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

– Learning
Nov 14 '18 at 14:16





headers: Headers {_headers: Map(1), _normalizedNames: Map(1)} ok: true status: 200 statusText: "OK" type: 2 url: "localhost:3000/report" _body: "[{"_id":"5bec00c1043e8b3070858e36","username":"NAME","created_date":"Nov 14, 2018","updated_date":"Nov 14, 2018","time":"4:32 PM","status":"D","v":0},,]" __proto: Body

– Learning
Nov 14 '18 at 14:16













Looking at your json, _body is already an array. Try this.reports = data._body;

– pixelbits
Nov 14 '18 at 14:19







Looking at your json, _body is already an array. Try this.reports = data._body;

– pixelbits
Nov 14 '18 at 14:19















i think loop is a problem if i print this {{reports}} it print but ngFor not working

– Learning
Nov 14 '18 at 14:22





i think loop is a problem if i print this {{reports}} it print but ngFor not working

– Learning
Nov 14 '18 at 14:22




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301802%2fcannot-find-a-differ-supporting-object-angular-7%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma