async fetchAndStoreRecords(): Promise<Records[]> {
this.subRecords = await this.afs.collection<Records>('records')
.valueChanges()
.subscribe((data: Records[]) => {
console.log('log before data saved');
this.records = data as Records[];
});
console.log('log before return');
return await this.records;
}
My issue lies in the order of execution of this code. The log before data saved
appears after the return statement, causing a delay in saving the data. I am seeking a solution to ensure that the function returns the records promptly and stores them in my this.records
array.