Upon executing the provided code, I noticed that the checkCard function is being triggered before the getTimecard function completes its execution.
getTimecard() {
this._service.getTimecard().subscribe(
data => {
this.sending = true;
this.timecards = data;
},
err => {
this.sending = false;
console.error(err);
},
() => {
this.sending = false;
}
);
}
checkCards() {
console.log('timecards', this.timecards);
//Additional code reliant on timecard data
}
async onSubmit() {
await this.getTimecard();
this.checkCards();
}
Could it be possible that the checkOverlap function is not waiting for the completion of the getTimecard function to fetch its data?