Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

614
Visualizações
Can't access multiple parameters of getStaticPaths from getStaticProps , Nextjs/Apollo/Graphql

Below you can check the code. I'm trying to use Id to identify single content and use titles for links,

when I console log params.title

console: android-paging-advanced-codelab

but

when I try to console log params.id,

console: undefined

I need to access both params inside the getStaticProps so I can use the exact data I need.

I did try context by passing context and using context.params.id but the result is the same.

read the code below and help me, please!

Here you can see the code of my getStaticPaths :

export async function getStaticPaths(){

  const { data } = await client.query({
    query: gql`
    query {
      postContents{
        data{
          attributes{
              post_card{
                data{
                  id
                  attributes{
                    TitleForLink
                  }
                }
              }
          }
        }
      }
    }
    `
  })
  
  const paths = data.postContents.data.map((item)=> {
    return {
      params: { 
        id: item.attributes.post_card.data.id.toString(), 
        title: item.attributes.post_card.data.attributes.TitleForLink.toString(), 
      }
    }
  })

  return {
    paths,
    fallback: false,
  }

}

And the code of getStaticProps:

export async function getStaticProps({params}){
 
  const { data } = await client.query({
    query: gql`
    query {
      postCards{
        data{
          id
          attributes{
            post_content{
              data{
                id
                attributes{
                  Title
                  Description
                }
              }
            }
          }
        }
      }
    }
    `
  })
  console.log(params.id)
  return {
    props: {
      content: data.postCards.data,
    }
  }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda