Here is my code
export default function Search({ res }) {
var arr = Object.entries(res)
console.log(arr)
return (
<div>
Here's the result :
<ol>
{arr.map((value, index) => {
<li key={index}>{value.title}</li>
})}
</ol>
</div>
);
}
export async function getServerSideProps({ params }) {
const { id } = params;
const req = await fetch(
`http://localhost:4000/reddit/${id}`
);
const res = await req.json();
return {
props: { res } // will be passed to the page component as props
};
}
At this point :
console.log(arr)
This line prints me a beautiful array with 100 subarrays because the fetching was good from the API...
Data looks like this array : [["0", {title: "I like eating", textValue: "Yes, I do"}], ["1", {title: "I like dirinking", textValue: "Yes, I do"}]]
But in the page I have only the markup
I don't succeed to know why...