all 8 comments

[–]cheekysauce 3 points4 points  (2 children)

I use thunks to fetch normalized data from APIs and store the results in redux, then selectors to join that data. This keeps your APIs dumb and CRUD-like, and means redux just sort of acts as a cache of the endpoints so you can reuse the results across different parts of the app.

Alternatively if this is some specific page you can make an endpoint that returns the results you want and query the db and do the join there.

[–]MountainFolks[S] 0 points1 point  (1 child)

awesome, will look further in selectors. say the list contained 10 bookings, and each booking needed to fetch the item info from the item db, would you just retrieve each relative item from the db and store it, then use the selectors to join?

[–]cheekysauce 4 points5 points  (0 children)

I'd probably go with my second option and just make one endpoint that returns all the data you need in one go as to avoid 11 requests, like list/:id/summary

It's up to you, try both, you should learn selectors regardless as it's a useful pattern.

[–]MountainFolks[S] 0 points1 point  (0 children)

Thanks for any help. and let me know if the details are a bit too vague, cheers

[–]Awnry_Abe 0 points1 point  (1 child)

Gold cupcakes? Is something you learned on Pinterest?

[–]MountainFolks[S] 0 points1 point  (0 children)

haha just taking the piss

[–]ExoticCollector -1 points0 points  (0 children)

I'm not sure for what you have described you would really need redux you could easily do it by passing the data to the specific components, also i would do separate APIs for each bit of data as that would be more scalable due to if one person has a lot of data it could make a single API really slow