using amp-list, how to access property outside of items array in JSON response

135 Views Asked by At

I am avoiding AMP-script for the purpose of learning to use the web-components well.

Using the amp-list component to search OMDb, I get back data with this structure (abbreviated for display):

{
  "Search": [
    {
      "Title": "RED",
      "Year": "2010",
      "imdbID": "tt1245526",
      "Type": "movie",
      "Poster": "https://m.media-amazon.com/images/M/MV5BMzg2Mjg1OTk0NF5BMl5BanBnXkFtZTcwMjQ4MTA3Mw@@._V1_SX300.jpg"
    },
    ...
    {
      "Title": "Red Riding Hood",
      "Year": "2011",
      "imdbID": "tt1486185",
      "Type": "movie",
      "Poster": "https://m.media-amazon.com/images/M/MV5BMTc4NjYyMzQ5MV5BMl5BanBnXkFtZTcwNjE5Mjc3NA@@._V1_SX300.jpg"
    }
  ],
  "totalResults": "5599",
  "Response": "True"
}

To print data from this response, I set the items attribute to "Search" as follows...

<amp-list ... items="Search">
  <template type="amp-mustache">
    <p>{{Title}}</p>
  </template>
</amp-list>

How can I also access the totalResults and Response properties that are returned outside of the Search object?

0

There are 0 best solutions below