title: Wait till the subscribe finishes then move on to next part of the code
body: <p>Have a subscription thats being called after everything else gets set but i wanna wait till the subscription finshes. T</p>
  
  <p>Tried using async await but that didnt work with me. No sure if I was doing it incorrectly</p>
  
  <pre><code>public getGlobeConfig() {
      this.sourceKey = 'test';query = 'query'
      // wait till this call finishes than hit the 
       console.log('htting')
      this.service
      .searchQuery(query)
      .subscribe(response =&gt; {
          this.sources = response.hits.hits.map(hit =&gt; 
          hit._source);
          if (this.sources.length &gt; 0) {
              this.availableMetadata = Object.keys(
                  this.sources[0].metadata[this.sourceKey]
              );
          }
      });
      console.log('hitting')
      return this.sources
  }
  </code></pre>
  
  <p>This.sources is reaching as undefined because this.sources is being set in the subscriptioon</p>