How to load data in the initialState from the database?

Friends, Hello.

There is a certain array of data stored in mongoDB with one hand. Is there a web app on react+redux on the other hand. How can I load the array data from database in that is labeled initialState, and only then render the app? Puzzled, help. Surely there is some standard solution to this problem. Thanks in advance.
July 9th 19 at 13:40
1 answer
July 9th 19 at 13:42
Solution
Typeset loader (spinner or whatever), which will revolve until the application is loaded.
Via XHR (e.g., axios, request-promise, fetch, etc.) loads the required data form the initialState and shove it in createStore().
When the application etrangeres - hide loader.

Something like this.
Promise.props({
 user: fetch('/user'),
 products: fetch('/products')
}).then(initialState => {
 const store = createStore(reducer, initialState);
 render(<provider store="{store}"><app></app></provider>, mountNode);
});
Thank you, very helpful - Drew1 commented on July 9th 19 at 13:45
I hope it is not necessary to mention that for all the Promise it is necessary to use Bluebird? - vito.Hoeg commented on July 9th 19 at 13:48

Find more questions by tags MongoDBNode.jsReactRedux