title: Iterate through JSON object in angular 6
body: <p>I am new to Angular and probably this might be a silly question. I am trying to get an api response and save it into an array. My API response looks like : </p>
  
  <pre><code>[
      {
          "name1": {
              "name": "name1",
              "api": {
                 //somedata
              },
              "t1p": {
                 //somedata
              }
          }
      },
      {
          "name2": {
              "name": "name2",
              "api": {
                  //somedata
                  }
              },
              "t1p": {
                  //somedata
              }
          }
      }
  ]
  </code></pre>
  
  <p>I get the response from the code </p>
  
  <pre><code>var data = [];
  
  makeRequest(): void {
        this.http
          .get(this.URL1)
          .subscribe((res: Response) =&gt; {
            this.data = res;
            console.log(this.data);
          }, err =&gt; console.log(err));
      }
  </code></pre>
  
  <p>Now I want to fetch the "name" value from each of the JSON object. I tried doing this:</p>
  
  <pre><code>var ids:string = [];
  
  for(let result of this.data){
              ids.push(result.name);
              console.log("Added"+result.name);
            }
  </code></pre>
  
  <p>But I am not able to achieve the same. Can anyone tell me what is wrong with the same. </p>