Hi all ๐
Got a noob question as I'm learning (more) about Next.js on the fly.
I'm fetching data (see below) and trying to access it in my component. However, the data won't show? Upon console.log'ing, I see it's undefined. No idea why. Again, prolly a rookie mistake but I'm just trying to understand (:
export const fetchData = async () => {
// From the Sanity tutorial, trying to fetch pets
const pets = await client.fetch(`*[_type == "pet"]`);
return {
props: {
pets,
},
};
};
So I have two questions, actually
- How can I 'know' what the type is of the returned props, namely
pets. Because I'm using TS - Maybe if I know 1 I know 2, but still sometimes a bit lost with
undefinedand all, why is itundefined?
Any help is much appreciated! ๐