I want to make a method that only makes another request when the before request return StatusCode 200. I'm using angular 15.
My home.component.ts
look like this and I want to todasGuias()
only make another request at a time.
todasGuias() {
this.page= 1;
while (this.page <= this.listaGuias.TotalPages) {
this.homeService.getGuias( this.year, this.month, this.glosadas, this.page)
.subscribe((data)=>{
this.listaGuias = data.Dados[0]
console.log(this.listaGuias.ResultList);
})
this.page++;
}
}
and my home.service.ts
look like this:
public getGuias( year: any, month: any, glosadas: any, page:any): Observable<any> {
const token = this.token.retornaToken();
const headers = new HttpHeaders({ Authorization: `Bearer ${token}` });
return this.http.get(API/list?TpoRelatorio=1
&SomenteGlosadas=${glosadas}
&Ano=${year}
&Mes=${month}
&Page=${page}
&Count=0`,{ headers }
)
}
any help?