getApplications(current_page: number) {
this.isBusy = true;
this.applicationDataSource = [];
this.applicationService.getApplication(current_page).subscribe(response => {
if (response['data']) {
this.pagination_meta = response['meta'];
response['data'].map((value: any, index: any) => {
var age:any;
this.applicationService.getAgeFromBirthday(value.order.reservation.customer.birthday)
.subscribe(res=>{
age = res;
})
let dataSource = {
'sample_id': value.order.ilummina_report_id ?
value.order.ilummina_report_id : '',
'date_of_blood_collection': value.date_of_blood_draw ?
value.date_of_blood_draw : '',
'patients_last_name': value.order.reservation.customer.last_name ?
value.order.reservation.customer.last_name : '',
'date_of_birth':value.order.reservation.customer.birthday + age,
'patients_first_name': value.order.reservation.customer.first_name ?
value.order.reservation.customer.first_name : '',
'number_of_fetuses': value.pregnancy_type,
'number_of_weeks_pregnant': value.patient_gestational_age_weeks + ' 週 ' +
value.patient_gestational_age_days + ' 日',
'test_plan': value.plan_component.plan,
'action': value.id,
'check_input': '',
'meta': value
}
this.applicationDataSource.push(dataSource);
On my service this is the API call
getAgeFromBirthday(birthday: string): Observable<any> {
return new Observable<any>((observer) => {
this.http.get(this.appSettings.getApiUrl() +
apiEndpoints.getAgefromBirthday(birthday), this.appSettings.getHeaders()).subscribe(response
=> {
observer.next(response);
observer.complete();
}, err => {
observer.next(false);
observer.complete();
})
})
}
I am getting http 429 . and when I try to console the result , the getAgefrombirthday executed last , that is why age is undefined when render , but later it will show it to console and http 429 error occurs ..
Please help