title: best way to store and process JSON data from httpClient get request in Angular
body: <p>I am new to Angular, and I'm working on a project with Ionic Angular. My goal is to use the httpClient and send get request to a Country api that will send me back a JSON of all the countries. The way I used to store the data is to create an interface matching the data type that I am receiving from and then subscribe to that observable and store the data into the array of the data type that I defined.</p>
  
  <p>But for the countries, the only thing I need is the name, is it possible to store the name of each countries into an array without defining the structure of the receiving JSON object, because it's very long and complex.</p>
  
  <p>This is the code that I am trying to do:</p>
  
  <p>Getting the countries as Observable. in the Country.Service file</p>
  
  <pre><code>  getCountry(): Observable&lt;any&gt;{
      return this.http.get&lt;any&gt;(this.url2);
    }
  </code></pre>
  
  <p>Declaring variable and store the data of countries:</p>
  
  <pre><code>public countries: any;
  
    storeCountry(){
      this.countryService.getCountry().subscribe(
        data =&gt; {
          this.countries = data;
        }
      );
  </code></pre>
  
  <p>This is what I'm trying to do, but I was not able to get the data into the countries variable to access it as array, when I console log the countries it is showing as undefined.</p>
  
  <p>What would be the best approach to what I'm trying to achieve? I would appreciate any help,</p>