I have Next JS project with static JSON placed in /pages/api/data.json that looks like this:
{
"Card": [
{ "title": "Title 1", "content": "Content 1" },
{ "title": "Title 2", "content": "Content 2" },
{ "title": "Title 3", "content": "Content 3" }
]
}
I'm trying to get the content from that JSON to load in a couple of sections like this:
import { Card } from "../api/data";
export const getStaticProps = async () => {
return {
props: { cardData: Card },
};
};
export default ({ cardData }) => (
<>
const card = cardData.title; console.log(cardData);
{ {cardData.map((cardData) => (
<div>
<h3>{cardData.title}</h3>
<p>{cardData.content}</p>
</div>
))}; }
</>
);
But I'm getting a Type: Undefined error and I'm pretty sure that's not how the function should look like.
Also, if I want to export that as a component that I can use in my index.js, would I have to name the export default function? repo link here: https://github.com/DoctorSte/remoteOS