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

179
Visualizações
NextJS getStaticProps / getStaticPaths typeError: response is not a function

I'm struggling with an error showing up in my terminal when testing on localhost. I've been getting an inconsistent message reading:

error - TypeError: response is not a function

I'm having trouble figuring out why it happens, because it only shows up on maybe 1 out of 10 refreshes of the page, and there are no useful messages in the browser console. I don't even know if the problem is triggered by getStaticPaths or getStaticProps, because I can't include one without the other.

Anyone see what I'm missing? I've simplified the code to this:

const Reviews = props => {
    console.log("Reviews rendering");
    return (
        <Fragment>word</Fragment>
    );
};
 export async function getStaticPaths() {
      let config = await import("../../config/config");
      let axResponse = await axios.get(`https://${config.default.domain}/api/get/ti.php`);
      return {
            paths: axResponse.data.items.map(item=>({ params: { code: item } })),
            fallback: true
      };
 };
 export async function getStaticProps(context) {
      let config = await import("../../config/config");
      let axResponse = await axios.get(`${config.default.apiEndpoint_static}&sft=reviews&code=${context.params.code}`);
      return {
            props: {
                 asdf: "zxcv"
            }
      };
 };

The import of config is just a local json file that has stuff like the api endpoint, domain name, etc. I have a feeling this might be what NextJS doesn't like, but I'm not sure. It does work though.

I've also verified that the responses from the api are valid json with the expected data. Basically, getStaticPaths is pulling a list of top items so that only those items will be pre-rendered on the server, and getStaticProps is pulling reviews for each item so that they can be displayed. I'm purposely not doing anything with the reviews in this simplified demo, I just wanted to leave the line there in case it's part of the problem.

And here's a longer snippet from the terminal. Every "Reviews rendering" line is me hitting refresh on the browser. Maybe the fact that it only seems to happen after I've changed the file is meaningful.. Further refreshes don't seem to trigger the message.

event - compiled successfully in 973 ms (1974 modules)
Reviews rendering
error - TypeError: response is not a function
wait - compiling /_error...
event - compiled successfully in 937 ms (1974 modules)
Reviews rendering
Reviews rendering
Reviews rendering

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