[Clarification] Doubling of code of requests?
Type of issue: Clarification of architecture
I really like the idea of js-stack-from-scratch
and js-stack-boilerplate
but I found 1 interesting thing. Why server rendered data differs from client rendered data?
Let's say we want to get list of posts. How do I make requests to API server in old SPA world without SSR? (simplified version)
- I have an dispatch in
componentDidMount
, which triggers an actions, which triggers a saga, which makes an API fetch call, so I get the posts. Yahoo!
How do I make requests to API server in new SPA world with SSR?
- I have an dispatch in
componentDidMount
, which triggers an actions, which triggers a saga, which makes an API fetch call, so I get the posts. Yahoo! - I found such thing as a
controller.js
which makes the same API call correspond to the component to preload global state. Huh?
Do I misunderstand somewhat? Why do we do it twice? Did you think about it?