Unable to retrieve reference data in Builder visual editor

Hey everyone,

I am currently using the second generation of the SDK for Builder. The tech stack that I am currently using for my project is NextJS 13, React along with the app directory. My intention is to query the page content using the content api (getContent) and get all the content, including the data in all the references. For some reason, when I do this, I am only able to retrieve the reference data of my custom blocks locally, not in the Builder visual editor. I’ve tried adding “includeRefs” on both getContent and the RenderContent component, as well as adding an options:{includeRefs: true}; on both. No matter what I do, includeRef’s data is always empty when I query the page model and need to do an additional check to see if it is in an iFrame so I can manually query it which is not the best solution.

I have included screenshots showing my page component querying for all the blocks in a specific url path which passes all the content into the RenderContent component. I was wondering, how can I get all the reference data in my individual custom components when querying for a page’s content or is it intended for me to need to manually render each and every component? I did not have this issue with the first generation of the SDK for Builder.


Hello @LestW,

You can try using enrich:true option

   options: {
      enrich: true,
    },

Let us know how that works for you. Thank you!

Hi, I have a question. enrich set to true does help to get the value of the reference type data but how about if you have reference type inside reference type, or said simply nested refs (2 or more levels deep). How can you then get the value of the nested refs ?

Here is a visual.

image

As seen in the image i have bottomNavigationData which is array of data, then i have navigationRef which is of type reference and i can get access to the value, and this is the first level reference.

But when i go to d.navigationRef.value.data.page the page is again a reference type but inside another reference type (second level ref) to which i can’t get the value for.

The enrich is set to true. But i think it is working just for the first level nested refs data. So my question is - is it possible, and if yes, then how do i get access to the 2nd, 3rd, 4th etc… level nested refs data(value) ?

Hello @Mehan,

To retrieve nested refs data beyond the first level, you’ll need to make additional fetch calls. These calls will help you access the 2nd, 3rd, 4th, and subsequent levels of nested data. Initially, the first level returns the ID of the reference data, which you can then use to further query deeper nested levels.

If you need assistance with implementing these additional fetch calls or have any further questions, feel free to ask.

Best regards,

1 Like