So the data type from getServerSideProps is not being passed to the page.
This is the model
export type TypeUser = {
_id?: Types.ObjectId;
name: string;
email: string;
image: string;
emailVerified: null;
profileDescription: string;
imageDownloadFormat: string;
};
This is my getServerSideProps
export const getServerSideProps: GetServerSideProps = async (ctx: GetServerSidePropsContext) => {
const session = await getServerSession(ctx.req, ctx.res, authOptions);
if (!session) {
return {
redirect: {
destination: "/",
permanent: false,
},
};
}
const response = await NextAPIClient.get(`/api/users/by-email/${session.user?.email}`);
const user: TypeUser = await response.data.data;
return {
props: { user },
};
};
and this is the NextPage
const ProjectsPage: NextPage<InferGetServerSidePropsType<typeof getServerSideProps>> = ({ user }) => {
console.log(user.name);
...
So basically I’m not getting type completion when I do user. something