Tracking and triaging of client issues across all Masa products
0
stars
0
forks
source link
[Problem]: I can't seem to figure out how to connect my request_list.json to my next.js. I want to be able to display this data in some sort of way please #3
I’m currently working on a Next.js project, and I’ve created a request_list.json file that contains a list of requests I want to display on a web page. However, I’m having trouble connecting this JSON file to my Next.js application. I would like to know the best practices for fetching this data and displaying it dynamically on a page.
Specifically, I’m interested in:
Location of the JSON File: Where should I place my request_list.json file within my Next.js project structure? Should it be in the public directory, or is there a better place for it?
Fetching the Data: What are the recommended methods for fetching JSON data in Next.js? Should I use static site generation (SSG) with getStaticProps, or is it more appropriate to use client-side fetching with React hooks? I want to ensure that the data is fetched efficiently and displayed correctly.
Displaying the Data: Once I have fetched the data, what’s the best way to display it? Should I use a simple list, or are there more advanced components or libraries you would recommend for rendering the data in a more user-friendly way?
Handling Errors: If there are issues while fetching the JSON data, how should I handle errors gracefully? I want to ensure that users have a good experience, even if the data fails to load.
Environment
Not entirely a problem
Masa Component
Other (please specify in description)
Version
Not sure
Peer ID
Not sure
Twitter Pro Account
No
What happened?
I’m currently working on a Next.js project, and I’ve created a request_list.json file that contains a list of requests I want to display on a web page. However, I’m having trouble connecting this JSON file to my Next.js application. I would like to know the best practices for fetching this data and displaying it dynamically on a page.
Specifically, I’m interested in:
Location of the JSON File: Where should I place my request_list.json file within my Next.js project structure? Should it be in the public directory, or is there a better place for it?
Fetching the Data: What are the recommended methods for fetching JSON data in Next.js? Should I use static site generation (SSG) with getStaticProps, or is it more appropriate to use client-side fetching with React hooks? I want to ensure that the data is fetched efficiently and displayed correctly.
Displaying the Data: Once I have fetched the data, what’s the best way to display it? Should I use a simple list, or are there more advanced components or libraries you would recommend for rendering the data in a more user-friendly way?
Handling Errors: If there are issues while fetching the JSON data, how should I handle errors gracefully? I want to ensure that users have a good experience, even if the data fails to load.
Steps to reproduce
1. 2. 3. ... Its not a bug
Relevant log output
No response
Additional context
No response