Tutorial on Next.js site (How to Load Data from a File in Next.js) doesn't work...
Unanswered
Brown bear posted this in #help-forum

Brown bearOP
So I'm trying to follow the tutorial on the NextJS site: https://vercel.com/guides/loading-static-file-nextjs-api-route
Basically, it doesn't seem to match up correctly to the files created when I run
Basically, it doesn't seem to match up correctly to the files created when I run
create-next-app
- I don't even have the pages
folder mentioned! How do I need to adapt this tutorial to make it work with the current version of Next.js? Thanks in advance!4 Replies

@Brown bear So I'm trying to follow the tutorial on the NextJS site: https://vercel.com/guides/loading-static-file-nextjs-api-route
Basically, it doesn't seem to match up correctly to the files created when I run `create-next-app` - I don't even have the `pages` folder mentioned! How do I need to adapt this tutorial to make it work with the current version of Next.js? Thanks in advance!

Next.js basically has two versions. In one you have the
Check if you have the
pages
folder, in the other you have the app
folder. create-next-app
will ask you which one you'd like to use ("Would you like to use App Router?").Check if you have the
app
folder.
@ncls. Next.js basically has two versions. In one you have the `pages` folder, in the other you have the `app` folder. `create-next-app` will ask you which one you'd like to use ("Would you like to use App Router?").
Check if you have the `app` folder.

Brown bearOP
oh wow, now I feel stupid
thank you!


Brown bearOP
So I had another crack at this with a new project based off the pages router... and I still don't seem to be able to get this working! Everything is in place, but I get the following error:
I've gone as far as to clone the tutorial repo, which worked fine... but then when I copied the edited files into my own project (after installing swr) I still get the same error message! Is there anything else I might be missing? It seems like it can't find the json file maybe, but it's definitely there!
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading 'name')
I've gone as far as to clone the tutorial repo, which worked fine... but then when I copied the edited files into my own project (after installing swr) I still get the same error message! Is there anything else I might be missing? It seems like it can't find the json file maybe, but it's definitely there!