Re:Next.js – A small framework for server-rendered universal...
by obilgic on Tuesday October 25, 2016 @04:35PM
(#12791435)
Don't fetch within a component. Write a helper function: getUser(). It should decide which method to use to retrieve data.
[ Parent
| on HN ]
Re:Next.js – A small framework for server-rendered universal...
by idbehold on Tuesday October 25, 2016 @04:42PM
(#12791496)
How would it decide? What does the server-side version do since it won't have access to the req or res objects at this level of the code? If the /api/user/:id route is restricted based on the cookies that get sent, how/where do you validate that the user is allowed to get data from that route when rendering server-side?
Re:Next.js – A small framework for server-rendered universal...
by Touche on Tuesday October 25, 2016 @05:54PM
(#12792045)
That would be the responsibility of the route code, not the code doing the fetch().
Re:Next.js – A small framework for server-rendered universal...
by idbehold on Tuesday October 25, 2016 @06:07PM
(#12792163)
Why would the route code need to know what data a deeply nested component needs? Making that the responsibility of the route code entirely defeats the purpose of an isomorphic/universal React application.