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

后端 未结 18 1203
逝去的感伤
逝去的感伤 2020-11-29 05:50

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\",
          


        
18条回答
  •  隐瞒了意图╮
    2020-11-29 06:16

    I had the same error because I have mapped the HTTP response like this:

    this.http.get(url).map(res => res.json);
    

    Note how I accidentally called .json like a variable and not like a method.

    Changing it to:

    this.http.get(url).map(res => res.json());
    

    did the trick.

提交回复
热议问题