Is there anything to do with synchronization when it comes to getStaticPaths and getStaticProps? #29256
Unanswered
vitthalzephyr
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a few articles which I am trying to pull and display using ISR feature. However I am getting a build error potentially due to synchronization issues.
Here is my getStaticPaths:
I am using mongoose to connect to database and get a list of all categories under which some articles exist. Now here is my getStaticProps:
Then while render, I am going through each article and displaying it's contents as :
Here build fails with error: TypeError: Cannot read property 'map' of undefined
I went through my database to check if at all there is any category for which articles aren't there (undefined), but I couldn't find any such issue. So it seems this is more of synchronization issue. Also the code works fine in dev run with the same database.
A quick fix is to say articles && articles.map....., but I am not convinced on the same. Is there something I am doing wrong with getStaticPaths or getStaticProps?
Beta Was this translation helpful? Give feedback.
All reactions