I am trying to pre-fetch data for my project in nextJS. It is a dynamic page that grabs the users ID and redirects them to their profile (url example: profile/0xab83). I am trying to use getServerSideProps, but it returns an empty object. The data I am fetching is from a sanity database. How can i fix this? I do not need the ID to fetch the data at all, but also I am unable to make this a static route.
Code:
export async function getServerSideProps() {
const query = `*[_type == "marketItems"] {
contractAddress,
}`;
const data = await client.fetch(query);
return {
props: {
data,
},
};
}
function profile(data) {
console.log(data)
return(<></>)
}