title: Angular wait for subscribe to finish
body: <p>I'm trying to implement a test application with Angular. The issue scenario is that I need to do a Get and return a value based on the data gotten from that Get request. See below:</p>
  
  <pre class="lang-js prettyprint-override"><code>public getNextId(entityName: string): number {
      console.info('Retrieving next ID for  ' + entityName);
  
      let seqId: SeqId;
  
      const url = `${this.apiURL}/${entityName}`;
  
      console.info('SeqID URL: ' + url);
  
      this.http.get&lt;SeqId&gt;(url)
          .subscribe((data: SeqId) =&gt; seqId = data); -&gt; 1
  
      /*Do something with seqId */ -&gt; 2
  
      return seqId.nextEntityId;
  }
  </code></pre>
  
  <p>The thing is that (2) executes before (1). When (2) is reached seqId variable hasn't been set yet.</p>
  
  <p>How can I do a Get, process the data retrieved and return something, all in the same method?</p>
  
  <p>Thanks in advance</p>