# \[solved\] NgFor only supports binding to Iterables such as Arrays

**URL:** <https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597>\
**Category:** ionic-v3\
**Created:** [August 5, 2016, 6:08am UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597 "2016-08-05T06:08:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![invalidname](https://avatars.discourse-cdn.com/v4/letter/i/e99b99/32.png) [@invalidname](https://forum.ionicframework.com/u/invalidname)\
**Post date:** [August 5, 2016, 6:08am UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/1 "2016-08-05T06:08:23Z")

</div>

I’m trying to access an isbn api to get a list of books based on the isbn number. My function in home.ts is:

```
 getBooks() 
  {
    this.isbnsource.getBooks(this.isbn).subscribe(
      data => { this.foundBooks = data.json();
       },
      err => console.error(err), 
      () => console.log('getBooks completed') 
      );
 }

```

In the provider, I’m simply accessing using the URL:

```
  getBooks(isbn) 
  {
    //let books = this.http.get(`http://isbndb.com/api/v2/json/3Q47UX0K/books?q=${isbn}`)
    let books = this.http.get(`http://isbndb.com/api/v2/json/3Q47UX0K/books?q=9780713126983`)
    return books; 
  }

```

And in the home.html page, the ngFor is:

```
 <ion-card *ngFor="let book of foundBooks">
        <ion-card-header>
            {{book.title}}
        </ion-card-header> 
    </ion-card>

```

Based on online searches, I have tried to do this.data = Array.from(this.data) but still kept getting the following error in Chrome:

```
lang.js:345 Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
plugin.js:32 Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
home.ts:35 Object {page_count: 1, current_page: 1, index_searched: "isbn", result_count: 1, data: Array[1]}
home.ts:36 getBooks completed
browser_adapter.js:86 EXCEPTION: Error in build/pages/home/home.html:19:14
browser_adapter.js:77 EXCEPTION: Error in build/pages/home/home.html:19:14BrowserDomAdapter.logError @ browser_adapter.js:77BrowserDomAdapter.logGroup @ browser_adapter.js:87ExceptionHandler.call @ exception_handler.js:58(anonymous function) @ application_ref.js:317schedulerFn @ async.js:132SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:120onError @ ng_zone.js:117onHandleError @ ng_zone_impl.js:67ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:77 ORIGINAL EXCEPTION: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.BrowserDomAdapter.logError @ browser_adapter.js:77ExceptionHandler.call @ exception_handler.js:67(anonymous function) @ application_ref.js:317schedulerFn @ async.js:132SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:120onError @ ng_zone.js:117onHandleError @ ng_zone_impl.js:67ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:77 ORIGINAL STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:77ExceptionHandler.call @ exception_handler.js:70(anonymous function) @ application_ref.js:317schedulerFn @ async.js:132SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:120onError @ ng_zone.js:117onHandleError @ ng_zone_impl.js:67ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:77 Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
    at new BaseException (exceptions.js:20)
    at NgFor.set [as ngForOf] (ng_for.js:49)
    at DebugAppView._View_HomePage0.detectChangesInternal (HomePage.template.js:295)
    at DebugAppView.AppView.detectChanges (view.js:234)
    at DebugAppView.detectChanges (view.js:339)
    at DebugAppView.AppView.detectViewChildrenChanges (view.js:260)
    at DebugAppView.AppView.detectChangesInternal (view.js:245)
    at DebugAppView.AppView.detectChanges (view.js:234)
    at DebugAppView.detectChanges (view.js:339)
    at DebugAppView.AppView.detectContentChildrenChanges (view.js:252)BrowserDomAdapter.logError @ browser_adapter.js:77ExceptionHandler.call @ exception_handler.js:71(anonymous function) @ application_ref.js:317schedulerFn @ async.js:132SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:120onError @ ng_zone.js:117onHandleError @ ng_zone_impl.js:67ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:77 ERROR CONTEXT:BrowserDomAdapter.logError @ browser_adapter.js:77ExceptionHandler.call @ exception_handler.js:74(anonymous function) @ application_ref.js:317schedulerFn @ async.js:132SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:120onError @ ng_zone.js:117onHandleError @ ng_zone_impl.js:67ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
browser_adapter.js:77 DebugContext {_view: _View_HomePage0, _nodeIndex: 28, _tplRow: 19, _tplCol: 14}BrowserDomAdapter.logError @ browser_adapter.js:77ExceptionHandler.call @ exception_handler.js:75(anonymous function) @ application_ref.js:317schedulerFn @ async.js:132SafeSubscriber.__tryOrUnsub @ Subscriber.js:225SafeSubscriber.next @ Subscriber.js:174Subscriber._next @ Subscriber.js:124Subscriber.next @ Subscriber.js:88Subject._finalNext @ Subject.js:128Subject._next @ Subject.js:120Subject.next @ Subject.js:77EventEmitter.emit @ async.js:120onError @ ng_zone.js:117onHandleError @ ng_zone_impl.js:67ZoneDelegate.handleError @ zone.js:327Zone.runTask @ zone.js:259ZoneTask.invoke @ zone.js:423
Subscriber.js:229 Uncaught EXCEPTION: Error in build/pages/home/home.html:19:14
ORIGINAL EXCEPTION: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
ORIGINAL STACKTRACE:
Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
    at new BaseException (http://localhost:8100/build/js/app.bundle.js:1741:23)
    at NgFor.set [as ngForOf] (http://localhost:8100/build/js/app.bundle.js:476:27)
    at DebugAppView._View_HomePage0.detectChangesInternal (HomePage.template.js:295:30)
    at DebugAppView.AppView.detectChanges (http://localhost:8100/build/js/app.bundle.js:29894:14)
    at DebugAppView.detectChanges (http://localhost:8100/build/js/app.bundle.js:29999:44)
    at DebugAppView.AppView.detectViewChildrenChanges (http://localhost:8100/build/js/app.bundle.js:29920:19)
    at DebugAppView.AppView.detectChangesInternal (http://localhost:8100/build/js/app.bundle.js:29905:14)
    at DebugAppView.AppView.detectChanges (http://localhost:8100/build/js/app.bundle.js:29894:14)
    at DebugAppView.detectChanges (http://localhost:8100/build/js/app.bundle.js:29999:44)
    at DebugAppView.AppView.detectContentChildrenChanges (http://localhost:8100/build/js/app.bundle.js:29912:19)
ERROR CONTEXT:
[object Object]

```

Any suggestions would be appreciated!

---

<div class="post-metadata">

**Author:** ![invalidname](https://avatars.discourse-cdn.com/v4/letter/i/e99b99/32.png) [@invalidname](https://forum.ionicframework.com/u/invalidname)\
**Post date:** [August 5, 2016, 6:33am UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/2 "2016-08-05T06:33:05Z")

</div>

I know I just posted the question but…I tried the solution from here: [Exception when iteration an rxjs observable · Issue #8728 · angular/angular · GitHub](https://github.com/angular/angular/issues/8728) where I converted the json data to array and it worked!

> ```
> getBooks() 
> {
> this.isbnsource.getBooks(this.isbn).subscribe(
> data => { this.foundBooks = data.json();
> this.foundBooks = Array.of(this.foundBooks); 
> },
> err => console.error(err), 
> () => console.log('getBooks completed') 
> );
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![HeyParas](https://avatars.discourse-cdn.com/v4/letter/h/f475e1/32.png) [@HeyParas](https://forum.ionicframework.com/u/HeyParas)\
**Post date:** [January 22, 2017, 10:24am UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/3 "2017-01-22T10:24:35Z")

</div>

Thanks mate you solved my problem and saved my time.

---

<div class="post-metadata">

**Author:** ![metadata\_javier](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@metadata\_javier](https://forum.ionicframework.com/u/metadata_javier)\
**Post date:** [February 3, 2017, 1:34pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/4 "2017-02-03T13:34:15Z")

</div>

I had the same issue, thanks for the solution.

---

<div class="post-metadata">

**Author:** ![peter9x](https://avatars.discourse-cdn.com/v4/letter/p/f17d59/32.png) [@peter9x](https://forum.ionicframework.com/u/peter9x)\
**Post date:** [October 29, 2017, 4:20pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/5 "2017-10-29T16:20:31Z")

</div>

Thanks pro. You’re the best.

---

<div class="post-metadata">

**Author:** ![sandeep1248](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sandeep1248](https://forum.ionicframework.com/u/sandeep1248)\
**Post date:** [December 26, 2017, 1:50pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/6 "2017-12-26T13:50:51Z")

</div>

thanks, we can also declare  
foundBooks:any=[];  
getBooks()  
{  
this.isbnsource.getBooks(this.isbn)…subscribe  
(  
Data =\> this.foundBooks:any= Data,  
error =\>  
{  
this.statusMessage =  
‘Problem with the service. Please try again after sometime’;  
});

```
 }
```

---

<div class="post-metadata">

**Author:** ![Dreaser](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@Dreaser](https://forum.ionicframework.com/u/Dreaser)\
**Post date:** [January 7, 2018, 7:27am UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/7 "2018-01-07T07:27:45Z")

</div>

I know this is marked as solved, but this was one of the dozen tabs i had open when troubleshooting a similar problem.

I’ve compiled some notes in an answer over on Stack Exchange

> <https://stackoverflow.com/questions/31490713/iterate-over-object-in-angular/48135166#48135166>

---

<div class="post-metadata">

**Author:** ![vijaykharage](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@vijaykharage](https://forum.ionicframework.com/u/vijaykharage)\
**Post date:** [February 22, 2018, 1:31pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/8 "2018-02-22T13:31:37Z")

</div>

Solved the problem, Thanks for the solution.

---

<div class="post-metadata">

**Author:** ![vidyakashikar](https://avatars.discourse-cdn.com/v4/letter/v/848f3c/32.png) [@vidyakashikar](https://forum.ionicframework.com/u/vidyakashikar)\
**Post date:** [April 3, 2018, 12:12pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/9 "2018-04-03T12:12:21Z")

</div>

thanks it is working for my code also .  
trying from 2 days to display data on html view.😀😀

---

<div class="post-metadata">

**Author:** ![sandeepjohnsonk](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/sandeepjohnsonk/32/127371_2.png) [@sandeepjohnsonk](https://forum.ionicframework.com/u/sandeepjohnsonk)\
**Post date:** [June 22, 2019, 7:25pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/10 "2019-06-22T19:25:34Z")

</div>

> [@invalidname](#):
>
> data =\> { this.foundBooks = data.json(); this.foundBooks = Array.of(this.foundBooks);

thanks buddy… 3 hours searched the script, finally got it

---

<div class="post-metadata">

**Author:** ![AjayT](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@AjayT](https://forum.ionicframework.com/u/AjayT)\
**Post date:** [June 24, 2019, 5:12pm UTC](https://forum.ionicframework.com/t/solved-ngfor-only-supports-binding-to-iterables-such-as-arrays/59597/11 "2019-06-24T17:12:24Z")

</div>

I am also having this problem ,while implementing this solution I caught up  
with this error TypeError: res.json is not a function at MapSubscriber
