title: How to access one element in a object json array and bind this data on the X-axis in Ionic 6 / Chartjs?
body: <p>I following a tutorial how to use ChartJS in ionic 6. I have a json response like this:</p>
  <pre><code>[
      {
          &quot;id&quot;: &quot;1&quot;,       
          &quot;name&quot;: &quot;Fruit&quot;,
          &quot;last_updated&quot;: &quot;2022-03-13T20:13:12.322Z&quot;
      }
  ]
  </code></pre>
  <p>I only want to have the <code>&quot;last_updated&quot;</code> in my response and convert this to an array and bind it to the X-axis in a chart with the framework ChartJS.</p>
  <p>This is my code to get the element and convert it to an array:</p>
  <pre><code>getLastUpdated() {
      var json;
      this.http.get(httpurl)
        .subscribe(data =&gt; {
          json = data;
          var datarray = [];
          for (var i of json.data) {
            datarray.push(i.last_updated)
            console.log(datarray);
          }
  
        })
    }
  </code></pre>
  <p>Then I call this method via a service like this:</p>
  <p><code>this.dataService.getLastUpdated(); </code></p>
  <p>Bind this data like this:</p>
  <pre><code>lineChartMethod() {
      this.lineChart = new Chart(this.lineCanvas.nativeElement, {
        type: 'line',
        data: {
          labels: dataarray,
          datasets: [
            {
              label: 'Test',
              data: [65, 59, 80, 81, 56, 55, 40, 10, 5, 50, 10, 15],
  
            }
          ]
        }
      });
    }
  </code></pre>
  <p>And in my HTML page I render the chart like this:</p>
  <pre><code> &lt;canvas #lineCanvas&gt;&lt;/canvas&gt;
  </code></pre>
  <p>I get an error like this in my console:</p>
  <p>ERROR TypeError: json.data is not iterable</p>
  <p>Can someone point me in the right direction?</p>