I'm facing an issue with retrieving data from a child array named store
within user data returned by an API. When trying to access this child array in my view, it keeps returning undefined
.
Code
export class TokoPage implements OnInit {
store= null;
token: any;
constructor(
private authService: AuthService,
private navCtrl: NavController,
private storage: NativeStorage,
) {
this.storage.getItem('token').then((token) => {
this.token = token;
}).catch(error => console.error(error));
}
ngOnInit() {
this.authService.user().subscribe((user) => {
console.log('auth user', user);
console.log('1', user['sotre']); //undefined
});
}
}
View
{{store.name}}
returned data
https://i.sstatic.net/q4wjS.png
Any ideas on how to address this?
Update
JSON.stringify(user)
results
{
"success":[
{
"id":1,
"name":"xxxxx",
"username":"admin",
"email":"xxxxx",
"phone":"xxxxx",
"avatar":null,"
coins":0,
"type":"admin",
"email_verified_at":"2019-08-13 14:08:09",
"created_at":"2019-08-13 14:08:09",
"updated_at":"2019-08-13 14:08:09",
"products":[{xxxxxxx}],
"addresses":[],
"wishlist":[],
"orders":[],
"store":{
"id":1,
"name":"xxxxx",
"url":"xxxxx",
"logo":null,
"banner":null,
"description":"xxxxx",
"kota_id":xxxxx,
"province_id":xxxxx,
"province":"xxxxx",
"kota":"xxxxx",
"address":"xxxxx",
"phone":"xxxxx",
"user_id":1,
"active":"yes",
"verified":"yes",
"best_seller":"yes",
"created_at":"2019-08-13 14:08:09",
"updated_at":"2019-08-15 09:17:40"
},
"rating":[]
}
]
}