Data on a page is not loading properly when navigated to using the url bar or on refresh, but loads when navigated to by using the button on sidebar (with a routerLink).
Basically the page sends API requests with a users accountID and returns the information for that account. But when I refresh the page the accountID is not getting retreived so the API requests don't work.
I get user$ from the store and then in ngOnInit I do:
this.user$.subscribe(user => {
if (user != null && user['id']){
this.accountId = user['account_id']
}
})
this.getAccountInfo(this.accountId);
I don't know why it works when navigated to with routerLink but not with the url bar or upon refreshing.
Can anyone help me out with getting the api request to work with the user's account ID on refresh?
Thanks for any help. I'm very new to angular and redux.
HAve you tried to put getAcocuntInfo inside the subscribe?
like:
this.user$.subscribe(user => {
if (user != null && user['id']){
this.accountId = user['account_id'];
this.getAccountInfo(this.accountId);
}
})