#Can anyone help me with this following issue?

16 messages · Page 1 of 1 (latest)

rustic rapids
#

I am unable to get response in RSC component from Route handler but getting expected response when called from postman, for code and more explanation: https://stackoverflow.com/questions/78645775/how-to-resolve-empty-response-from-route-handler-when-rsc-component

coarse ospreyBOT
#

🔎 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)

pulsar plume
#

trpc follows the same approach by the way. there is a context spanning the whole app which stores the cache data

#

while the RSC part of the app router is equivalent to the SSG/SSR helpers of trpc

rustic rapids
#

@pulsar plume i am sorry i pasted the wrong stackoverflow link

pulsar plume
# rustic rapids <@484037068239142956> i am sorry i pasted the wrong stackoverflow link

remove the route handler and just use the server-side logic directly in your server component

import ProductSection from '@/app/_components/ProductSection';
import React from 'react'
// import { unstable_noStore as noStore } from 'next/cache';
import base_url from '@/app/_util/StrapiConfig';

const Products = async ({ params }) => {
  const merchantSlug = params?.merchantSlug || process.env.NEXT_PUBLIC_MERCHANT_NAME;

  //...
  const response = await fetch(base_url +
        `/products?populate=*&attributes[merchant][data][attributes][slug]=${slug}`, {
        headers: {            
            'Authorization': `Bearer ${process.env.NEXT_PUBLIC_STRAPI_TOKEN}`,
        },
    });    
    const products = await response.json();

  console.log("products in page.js", JSON.stringify(products, null, 2));

  return (
    <div className='mt-10 sm:px-10 md:px-20'>
      <ProductSection productList={products} />
    </div>
  )
}

export default Products;
river pulsar
# rustic rapids I am unable to get response in RSC component from Route handler but getting expe...

one question here: assume the first load on the LandingPage is done through server side function calls (executed on the server , since it is an Route Handler). Like caller.user.findBy() whereas on the client, this would be a useQuery call. When you say "there is a context spanning the whole app which stores the cache data" , are you suggesting the cache is common to both server and client? or is the caching behaviour is offered for free by react-query

pulsar plume
#

please open a new post

rustic rapids
river pulsar
#

(Apologies) asked in the same thread since it was slightly related.

pulsar plume
pulsar plume
rustic rapids
#

Ok thank you for the help!