I am learning react and am trying to debug using console.log, but I cannot find a place to put them where they actually fire. The below function sends a data request and I want to see how the data object is formatted, but console.log will not show me anything. Any ideas?
// This function gets called at build time
export const getStaticPaths: GetStaticPaths<ParsedQueryParams> = async ({
locales,
}) => {
invariant(locales, 'locales is not defined');
const data = await client.types.all({ limit: 100 });
//This does not log anything.
console.log(data);
const paths = data?.flatMap((type) =>
locales?.map((locale) => ({ params: { pages: [type.slug] }, locale }))
);
// We'll pre-render only these paths at build time also with the slash route.
return {
paths: paths.concat(
locales?.map((locale) => ({ params: { pages: [] }, locale }))
),
fallback: 'blocking',
};
};
CodePudding user response:
getStaticPaths
is run server-side, that is why you won't see anything in you web browser console. You can see the logs in you node.js output.
More information in the Next.js documentation about Static Site Generation