Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I work on angular 8 i have two subscribe
i need to execute first subscribe and after finish
execute second subscribe
but i don't know how to make it please ?
first function i need to execute is
getactivesession

second function i need to execute it
compareexcel
so how to do that please ?

What I have tried:

 service 
public getActiveSessions(flagButton:number): Observable<boolean> {
    return this.http.post<boolean>(this.url + 'Z2Delivery/getActiveSessions',flagButton);
  }
 public  CompareExcel(selectedoptionsId:Number,file:any):Observable<boolean> 
  {
    const formData: FormData = new FormData();
    formData.append('file', file,file.name);
    formData.append('selectedoptions',selectedoptionsId.toString());
  return  this.http.post<boolean>(this.url + 'Z2Delivery/CompareExcel',formData);
  }
 PostUpload(selectedoptionsId:Number, file:any):Observable<any>
  {
    const formData: FormData = new FormData();
    formData.append('file', file,file.name);
    formData.append('selectedoptions',selectedoptionsId.toString());
   
    return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{observe: 'response',responseType: 'blob' });
    
  }

execute it first
this._dataService.getActiveSessions(flagButton).subscribe(resp => {
      if (resp) {
        alert('There are active session working')
      } else {
        console.log('nooo');
      }
    });

execute it second
this._dataService.CompareExcel(this.selectedoptions,this.fileToUpload).subscribe(resp => {
        if (resp) {
          this._dataService.PostUpload(this.selectedoptions,this.fileToUpload)
      .subscribe(blob => {
      saveAs(blob.body, this.fileToUpload.name +'.xlsx');
       });
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900