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

214
Views
does api need to support query parameters to use getstaticprops and getstaticpaths?

when I' trying to fetch data from my api its not working.

export async function getStaticPaths() {
  const res = await fetch("https://domainname/api/vb1/category-tree")
  const data = await res.json();
  const content = data["data"]


  const paths = content.map(pageName =>{
    // console.log(pageName.id)
      return {
          params: {id: pageName.id.toString()}
      }
   
  })
  return {
    paths,
    fallback: false // true or 'blocking'
  };
}

export async function getStaticProps(context) {
  const id = context.params.id
   console.log(id)
  const res = await fetch("https://domainname/api/vb1/category-tree/" + id  )
  const data = await res.json()

 
  
  return {
    props: {
      pages: data
    },
  }
}

Error :FetchError: invalid json response body at https://domainame/api/vb1/category-tree13 reason: Unexpected token < in JSON at position 0

Now my question is does my API need to support query parameter to work with id?

about 4 years ago · Juan Pablo Isaza
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!