title: How to wait for function with subscribe to finish in angular 8?
body: <p>I want to wait for one function to finish before executing the function next to it.
  I have one function called <strong>getData()</strong> in which http call occurs which returns an observable. The second function <strong>checkDuplicate()</strong> we have subscribed to that function <strong>getData()</strong> . and we have third function called <strong>proceed()</strong> in which we call the <strong>checkDuplicate()</strong> function and once the <strong>checkDuplicate()</strong> function is completed, we are calling <strong>alert(&quot;finished&quot;)</strong>. But the issue here is even before <strong>checkDuplicate()</strong> function is completed, alert has been triggered.</p>
  <p>find the code for better clarification:</p>
  <pre><code>getData(): Observable&lt;any&gt;{
    return this.http.get&lt;any&gt;(URL...);
  }
  
  checkDuplicate(){
  
  return this.getData().subscribe(response =&gt; {
     if(response){
        console.log(&quot;Inside&quot;);
    }
  });
  }
  
  proceed(){
   this.checkDuplicate();
   console.log(&quot;finished&quot;);
  }
  </code></pre>
  <p><strong>Actual Result</strong></p>
  <p>finished</p>
  <p>Inside</p>
  <p><strong>Expected result</strong></p>
  <p>Inside</p>
  <p>finished</p>
  <p>I have tried <strong>asyn/await</strong> to wait for checkDuplicate() function to finish. But still no use.
  It would be grateful if u share the solution.
  Thanks in Advance !!!</p>