title: Wait for Api call to complete in Angular 8 error shows undefined
body: <pre><code> if(this.datashare.selectedtableId!=null) {
       console.log( &quot;inside if condition&quot;);
       let resp= this.http.get(this.global.apiUrl+&quot;columns/&quot;+this.datashare.selectedtableId);
       resp.subscribe((data)=&gt;this.users=data);
       console.log(this.users);
       this.count=this.users.length;
    }
  </code></pre>
  <p>when I console the users it shows all the data from API in my console like that <code>(console.log(data))</code> But in my component, I try to get the data at the starting of the page by calling the service and assign it to a local variable it is giving undefined.</p>