#Send data in original response or make API calls?

2 messages · Page 1 of 1 (latest)

golden maple
#

Hi again,

I have products I want to sell on my page, which are represented via a <Product /> tag. I was debating whether or not it was a better idea to prop drill JSON data for the component into all of the products on the initial page load, or if it would make more sense to just pass in a product ID which can be queried from my client API once the initial page has loaded?

JSON Example:
<Product jsonData={productJson[0]} /> - Product component will not query database, since the JSON data was sent on the initial response.

API Example:
<Product productID=0 /> - Product component will query client API with product 0 and display it that way, so the page should load faster since there isn't any large data or processing to be done for the product. This is done for all components, so I believe multiple API calls.

I think I heard that NextJS will add placeholders while the page is loading and all the JS is running, but I'm not sure if it's for this use case or not.

Thanks!

agile baneBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)