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

226
Vistas
Fetching data in next.js returning undefined

i'm trying to fetch data from from this API https://rapidapi.com/apidojo/api/shazam using next.js but i'm getting undefined and i don't know what is the problem, here's a snippet of the code, i'll be very glad if someone could help me understand what i'm doing wrong.

export async function getServerSideProps(context) {
  const res = await fetch(
    'https://shazam.p.rapidapi.com/charts/track?locale=en-US&pageSize=20&startFrom=0',
    {
      method: 'GET',
      headers: {
        'x-rapidapi-host': 'shazam.p.rapidapi.com',
        'x-rapidapi-key': 'my_key',
      },
    },
  );

  const data = await res.json();

  if (!data) {
    return {
      notFound: true,
    };
  }

  return {
    props: {
      data: data,
    },
  };
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this code snippet. It will provide you a better perspective also it will throw some errors, if any

fetch("https://shazam.p.rapidapi.com/charts/track?locale=en-US&pageSize=20&startFrom=0", {
    "method": "GET",
    "headers": {
        "x-rapidapi-host": "shazam.p.rapidapi.com",
        "x-rapidapi-key": "*****"
    }
})
.then(response => {
    console.log(response);
})
.catch(err => {
    console.error(err);
});
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