M
M
markmoskalenko2017-10-01 19:10:36
Angular
markmoskalenko, 2017-10-01 19:10:36

How to organize getting data from api if the data is not in the store?

Good afternoon!
I have an app in which some data from api is loaded on the main one. When I click on an item, I go to the item view page. As long as it's done in this order, everything is ok. In item view I get an element from store. But if I reload the page (f5), then the store will be empty and I will not be able to display the data of the desired item. How can I check if there is data in the store and if not, write the data there. Of course you can in the component .. but maybe you can somehow automate this in effect or somewhere else? Please tell me how to solve this nicely.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Mazhekin, 2017-10-15
@mazhekin

The problem is very simple, make a call to dispatch (receive data) not on the main page, but in the component that is the parent (routes must be written accordingly), all pages are of the type that is registered in index.html. If it is necessary for only for the pages of a section, then in the parent of this entire section.
The point is that getting to any page with a parent (and there is a call there) in any way, this call will be made once, and then going through the child routes it will no longer be called

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question