avitorio / outstatic

Outstatic - A static CMS for Next.js
https://Outstatic.com
MIT License
2.67k stars 157 forks source link

getDocuments errors with msg.startsWith is not a function when collection doesn't exist #120

Closed rinheimerle closed 1 year ago

rinheimerle commented 1 year ago

Provide environment information

Environment: locally NextJS version 13.4.12

What browser are you using? (if relevant)

Firefox 116.02

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

Recently, I used getDocuments following the basic fetching data example.

The function continually errors with msg.startsWith is not a function.

After some debugging, I noticed the collection hadn't been populated yet in my outstatic/content folder.

Expected Behavior

Ideally, outstatic would return a more meaningful error message, perhaps something like "collection doesn't exist".

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/rinduggan/portfolio

To Reproduce

  1. Use the getDocuments function, following the fetching data example.
  2. For the first parameter, pass in a collection name that doesn't exist in the outstatic/content folder.
avitorio commented 1 year ago

Hey @rinduggan, it seems this is resolved based on our discord chat. Would it be possible for you to comment a solution? Thanks