Hi I managed to get my slices to work with content relationships but slice simulator isn't receiving this data so I can't preview data or get screenshots.
I have a testimonials slice that pulls in data from a testimonials custom type.
I am using Prismic with NextJS.
My homepage is coded like this.
import { createClient } from '../prismicio';
import { SliceZone } from '@prismicio/react';
import { components } from '../slices/index';
import Layout from '../components/Layout';
export default function Home({ layout, home }) {
return (
<Layout layout={layout}>
<SliceZone
slices={home.data.slices}
components={components}
/>
</Layout>
);
}
export async function getStaticProps({ params, previewData }) {
const client = createClient({ previewData });
const layout = await client.getSingle('layout');
const home = await client.getSingle('homepage', {
fetchLinks: 'testimonials.testimonial',
});
return {
props: {
layout,
home,
},
};
}
I am pulling in data in my slice with
slice.primary.testimonialRelationships.data.testimonial
I works fine when I view page as a whole at localhost:3000 but when in slice simulator (even for other slices now) I'm getting this error.
TypeError: Cannot read properties of undefined (reading 'testimonial')