Accessing page version to set version to load

Builder content link

Builder public api key
f32bb69ae2034b759083c460e6a420fb

What are you trying to accomplish
I have two versions of my home page with the same url. I want to load either version 1 or version 2 based on a property value coming back from an API call. I’m making the call on the page code, I’ve retrieved the property, and I can redirect to a website based on that property. I just can’t figure out how to access different versions of the page.

Or perhaps there’s a better way altogether.

Code stack you are integrating Builder with
Conscia

Hi @maria Welcome to Builder.io Forum!

You can refer to the below code for your reference:-

export const getContentWithInfo = (content?: Content) => {
  if (content) {
    const cookieValue = builder.getCookie(`builder.tests.${content.id}`);
    const cookieVariation =
      cookieValue === content.id ? content : content.variations?.[cookieValue];
    const variationName =
      cookieVariation?.name || (cookieVariation?.id === content.id ? 'Default variation' : '');

    return {
      ...content,
      variationId: cookieValue,
      testVariationId: cookieValue,
      testVariationName: variationName,
    };
  }
  return null;
};

Let us know if you’ve further questions!

Thank you!! Directions have changed, I’ll have to come back to this later to test it out.