I am calling a API service and assigning API response to any[] type.
Problem is method was execution was completed without waiting API response completes?
Below is my code
Component.ts
  this.catalogService.getCatalogsData().subscribe((data => {
     this._catalogData=data;
      console.log("catalogService function execution done!");
   })); 
service.ts
public responseData:any=[];
 constructor(private http: HttpClient) { 
      }
    public getCatalogsData(){
      debugger;
           this.http.get(this.APIUrl}}).toPromise().then(  
                data => {  
                      this.responseData = data as string [];  
                      console.log("API Response completed");
                  }  
              ); 
       return this.responseData;
      }
Logs Output: -
catalogService function execution done!
API Response completed
Expected OutPut:-
API Response completed
catalogService function execution done!
 
    