I have a static JSON file for now, but I plan on fetching API data in the future. Since I’m new to Next.js, I’m testing out some simple code. When I run my project, I see that the [{"default":"data"}]
default parameter value is displayed, but not the testData.json
file. I know getStaticProps isn’t necessary in this case, but I would like to learn how to use it. Any ideas what went wrong? 🙁
<code>import data from "../testing/testData.json"
export default function OrderList({orders = [{"default":"data"}]}) {
return(
<div>
<h2>Order List</h2>
<div> {JSON.stringify(orders, null, 2)} </div>
</div>
)
}
export async function getStaticProps() {
return {
props: {
orders: data
},
}
}
</code>
<code>import data from "../testing/testData.json"
export default function OrderList({orders = [{"default":"data"}]}) {
return(
<div>
<h2>Order List</h2>
<div> {JSON.stringify(orders, null, 2)} </div>
</div>
)
}
export async function getStaticProps() {
return {
props: {
orders: data
},
}
}
</code>
import data from "../testing/testData.json"
export default function OrderList({orders = [{"default":"data"}]}) {
return(
<div>
<h2>Order List</h2>
<div> {JSON.stringify(orders, null, 2)} </div>
</div>
)
}
export async function getStaticProps() {
return {
props: {
orders: data
},
}
}