В вашем коде у вас есть следующее:
this.afauth.auth.onAuthStateChanged( async function(user) {
if (user) {
// User is signed in.
await this.storageService.ready()
const name = await this.storageService.get('name')
const business_name = await this.storageService.get('business_name')
} else {
// No user is signed in.
}
});
Вы должны изменить его на следующее:
this.afauth.auth.onAuthStateChanged( async ((user) => {
if (user) {
// User is signed in.
await this.storageService.ready()
const name = await this.storageService.get('name')
const business_name = await this.storageService.get('business_name')
} else {
// No user is signed in.
}
});
Использовать функцию стрелки, которая использует лексическую область, что означает, что вы будете быть в состоянии прочитать переменную, определенную вне этой функции.