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');
});