Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
getServersideProps not displaying anything

Hi I´m trying to fetch data and display it in a list but somehow it isn´t working. Can someone tell me whats wrong with the following function? It isn´t displaying anything or it is telling me that the data isn´t valid as child props. thanks for answers.

export async function getServerSideProps(context) {
  const res = await fetch('https://jsonplaceholder.typicode.com/posts')
  const data = await res.json()

  return {
    props: { data }, // will be passed to the page component as props
  }
}


export default function Home({data}) {


  return (
    <div>
      <h1>Hello World</h1>
      <div>
        {
          data.forEach(item => {
            return <li>{item.title}</li>
          })
        }
      </div>
    </div>
  )
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

return (
  <div>
    <h1>Hello World</h1>
    <ul>{data.map(item => (<li key={item.title}>{item.title}</li>)}</ul>
  </div>
)

key should be some unique value (see React docs).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!