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

132
Views
nextjs fetch data not showing in template and how to prevent fetch url calling two times

I can see my my api data from my terminal and it's also calling two time. I also want to display data in my page template. But I don't know where I am doing mistake and any data not showing in my template:

here is my code:

export default function Content({ blog }) {
  return (
        <>
          {blog.map((blogs) => {
                  {
                    blogs.blog_title;
                  }
                })}      
                
        </>
  );
}


export async function getServerSideProps() {
  // Fetch data from external API

  const url = "http://127.0.0.1:8000/blog-api";

  const headers = {
    "Content-Type": "application/json",
    Authorization: "<secret>",
  };

  const res = await fetch(url, { headers: headers });
  const data = await res.json();
  console.log(data);
  // Pass data to the page via props

  return {
    props: {
      blog: data,
    },
  };
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You forgot to return the value from the .map method

export default function Content({ blog }) {
  return (
    <>
      {blog.map((blogs) => <span key={blogs.id}>{blogs.blog_title}</span>)}      
    </>
  );
}
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!