You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Strange when I set fallback to true it works but produces the 'can't set headers after sent to client' error but getServerSideProps works fine. There's nothing more to the code just what I pasted above
Thanks
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using shopify's JavaScript buy sdk;
``export const getStaticPaths = async () => {
const products = await client.product.fetchAll();
const fetchedProducts = JSON.parse(JSON.stringify(products));
const paths = fetchedProducts.map((product) => ({
params: {
id: product.id,
},
}));
return {
paths,
fallback: false,
};
};
export const getStaticProps = async ({ params }) => {
const { id } = params;
try {
const product = await client.product.fetch(id);
const json = JSON.stringify(product);
return {
props: {
product: json,
},
};
} catch (error) {
console.error(error.message);
}
};
Strange when I set fallback to true it works but produces the 'can't set headers after sent to client' error but getServerSideProps works fine. There's nothing more to the code just what I pasted above
Thanks
Beta Was this translation helpful? Give feedback.
All reactions