0

I'm new to Polymer and I'm trying to loop over an API response using the iron-ajax element and I'm running into troubles. The error I'm getting is: polymer-micro.html:260 [dom-repeat::dom-repeat]: expected array foritems, found Object

This is what I'm using:

<dom-module id="untappd-data">
  <template>
    <style>
      :host {
        display: block;
        box-sizing: border-box;
      }

    </style>

    <iron-ajax
        auto
        url="https://api.untappd.com/v4/user/checkins/jimouk?client_id=[hidden]&client_secret=[hidden]"
        handle-as="json"
        last-response="{{response}}"></iron-ajax>
        <template is="dom-repeat" items="{{response.response.checkins}}">
          {{item.name}}
        </template>
  </template>
</dom-module>




 <script>
    Polymer({
      is: 'untappd-data',

      properties: {
          owner: {
            value: 'polymer',
            notify: true
          },

          url: {
            computer: 'computeUrl(owner)'
          }
        }
    });
  </script>

I understand that the dom-repeater element only loops over arrays but I'm wondering if there's a certain method I should be following with Polymer instead of moving all of those objects into an array with traditional Javascript.

James Ives
  • 3,177
  • 3
  • 30
  • 63
  • 1
    http://stackoverflow.com/questions/30781500/how-to-use-dom-repeat-with-objects-instead-of-arrays-in-polymer-1-0 – 2pha Jun 26 '16 at 02:06
  • I have looked at this, but cannot seem to get this method working with iron-ajax, I'm guessing I'm missing something? – James Ives Jun 26 '16 at 02:09
  • can you show your response data – Zohaib Ijaz Jun 26 '16 at 02:09
  • No need! Figured it out. I was targetting response.response.checkins and that wasn't the array, the answer was response.response.checkins.items. I'll close this, thanks! – James Ives Jun 26 '16 at 02:12

0 Answers0