Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
getStaticPaths array.map isn't a function when deploying to Vercel

Code is below, the dev server works perfectly fine without error, however when I try to deploy the site I get this error.

> Build error occurred
TypeError: artists.map is not a function
    at getStaticPaths (/vercel/path0/.next/server/pages/artists/[slug].js:106:24)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async buildStaticPaths (/vercel/path0/node_modules/next/dist/build/utils.js:498:31)
    at async /vercel/path0/node_modules/next/dist/build/utils.js:641:119
    at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:74:20) {
  type: 'TypeError'
}
export async function getStaticProps({ params }) {
  const siteSettings = await fetcher("http://localhost:3000/api/settings");
  const artists = await fetcher(
    `${process.env.URL}/api/artists/${params.slug}`
  );
  const artist = artists.allArtist[0];

  return {    
    props: {    
      siteSettings,    
      artist,    
    },    
  };    
} 

export async function getStaticPaths() {    
  const artists = await fetch(`${process.env.URL}/api/artists`);    
     
  return {                                                                                                           
    paths: artists.map((artist) => {                                                                                 
      return {    
        params: {    
          slug: artist.slug.current,    
        },    
      };    
    }),    
    fallback: false,    
  };    
}    

How would I go about fixing this error, as I said it works perfectly fine in the dev server with no console logs containing any errors.

Any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I attempted writing the API route logic directly in the getStaticProps function and this fixed the error @juliomalves also posted this link which suggests a similar answer: Fetch error when building Next.js static website in production

Thanks for the help.

Mac

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda