How to properly chain HTTP calls; I have an issue with the NEKDASH
webservice.
vue-general.ts
export class VueGeneralComponent implements OnInit {
private unsubscribe$ = new Subject<void>();
vueGenerale: {
preaPerimes: Number;
preaNonTraiter: Number;
clientDebiteurTit: Number;
}
constructor(private service: VueGeneralService, private router : Router) {
this.vueGenerale = {
preaPerimes : -1,
preaNonTraiter : -1,
clientDebiteurTit : -1
}
}
ngOnInit(): void {
this.getVueGeneral();
}
ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}
getVueGeneral(): void {
this.service.getVueGeneral().pipe(
takeUntil(this.unsubscribe$)
).subscribe(res => {
this.vueGenerale.preaNonTraiter = res.PREANONTRAITER;
this.vueGenerale.preaPerimes = res.PREAVISPERIME;
this.vueGenerale.clientDebiteurTit = res.CLIENTDEBITIT;
})
}
getClass(value) {
if (value == 0) {
return 'green-alert-card';
} else if (value > 0) {
return 'red-alert-card';
} else {
return 'gray-alert-card';
}
}
goTo(dest: string) {
this.router.navigateByUrl(`/dashboard/${dest}`);
}
}
vue-general.service.ts
@Injectable()
export class VueGeneralService {
private readonly api: string = environment.api;
constructor(private http: HttpClient, private store: Store) { }
getPreavisPerime(): Observable<PreavisResponse> {
return this.http.post<PreavisResponse>(this.api + `/NEKPREP`,{
FILTRE:{
STATUT: 2,
MODE : 'PREAP',
}
}, {});
}
getPreavisNonTraiter(): Observable<PreavisResponse> {
return this.http.post<PreavisResponse>(this.api + `/NEKPREP`,{
FILTRE:{
STATUT: 1,
}
}, {});
}
getPreavisNonTraiterListe(client: string): Observable<PreavisATraiterResponse> {
return this.http.post<PreavisATraiterResponse>(this.api + `/NEKPREL`,{
CUSTOMER:{
REFERENCE : client
},
FILTRE:{
STATUT: 1,
MODE: ""
}
}, {});
}
getClientsDebiteursTitres(): Observable<ClientDebiteurTitre> {
return this.http.post<ClientDebiteurTitre>(this.api + `/NEKCLDT`,{
PAGEIN: {
NTH: 1,
SIZE: 999
}
}, );
}
getVueGeneral(): Observable<VueGenerResponse> {
return this.http.post<VueGenerResponse>(this.api + `/NEKDASH`,{});
}
}
Thank you in advance for your help.