Replies: 1 comment
-
You are posting in the wrong repo. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using Next.js 14.2.3 and attempting to fetch a list of products from Firestore using the getProducts function from @stripe/firestore-stripe-payments in getServerSideProps. However, I'm encountering a serialization error:
Server Error
Error: Error serializing .products returned from getServerSideProps in "/".
Reason: undefined cannot be serialized as JSON. Please use null or omit this value.
Here is the relevant part of my code:
What I Tried:
I added error handling for the getProducts call to ensure that it logs any issues.
I attempted to sanitize the products array by converting undefined values to null using JSON.stringify and JSON.parse.
I restarted Firebase multiple times, created a new database, and set up new Stripe products.
I verified that the collection of products exists in my Firebase database.
I confirmed that Firebase is properly attached to my app, as new users are successfully added to the Firebase database upon registration. Despite these efforts, the serialization error persists, indicating that there might still be an undefined value within the products array.
I expected the getServerSideProps function to fetch the products and other movie data without encountering serialization issues, allowing the products array to be passed to the component without any errors.
I copied my question from stackoverflow : https://stackoverflow.com/questions/78502654/next-js-14-undefined-value-error-when-serializing-products-in-getserversideprop
Beta Was this translation helpful? Give feedback.
All reactions