title: Angular: How to use a Service to fetch data from server and store in an array?
body: <p>I have a service which calls the <a href="https://github.com/PokeAPI/pokeapi" rel="nofollow noreferrer">PokéAPI</a> at <code>https://pokeapi.co/api/v2/pokemon/</code>.</p>
  <p>If you don't specify the Pokemon you want returned, the API will return a paginated list of resources, which contains URLs for Pokemon.
  <code>https://pokeapi.co/docs/v2#pokemon-section</code></p>
  <p>I want to store that list of URLs inside a local array for my service.</p>
  <p>I have tried:</p>
  <pre><code>getListOfPokemonUrls(): Observable&lt;any&gt; {
      return this.http.get&lt;any&gt;(this.pokeApiUrl)
        .pipe(
          map((response: any[]) =&gt; this.pokemonResources = response.results)
        );
    }
  </code></pre>
  <p>In my constructor (for testing purposes):</p>
  <pre><code>const y = this.getListOfPokemonUrls();
  </code></pre>
  <p>However, when I step over that function <code>this.pokemonResources</code> array is empty.</p>