NextJs how to deal with fetching and a loop

I have a question how can I deal with fetching through loop in getStaticProps, because when I do that the array is empty. It is caused by asynchronous code. If I pass ID array and put logic into react component it works fine. Should I stick with component approach or do it in getStaticProps. If… Read More NextJs how to deal with fetching and a loop

How to get full browser url in next js, getServerSideProps

Now, i’m in http://localhost:3000/, but on prod i will be in a different url, for example http://example.com/, how can i get full browser url in getServerSideProps? I have to get http://localhost:3000/ or http://example.com/, if string will not contain port, it will be ok >Solution : ‘next/router’ provide a couple of methods too, which you can… Read More How to get full browser url in next js, getServerSideProps

Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types

I am using prisma and nextJS. When i try to retrieve the content from prisma in getStaticProps it does fetch the data but i can’t pass it on to the main component. export const getStaticProps = async () => { const prisma = new PrismaClient(); const newsLetters = await prisma.newsLetters.findMany(); console.log(newsLetters); return { props: {… Read More Reason: `object` ("[object Date]") cannot be serialized as JSON. Please only return JSON serializable data types