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

92
Vistas
How do I wait for a promise in a sync function

I am making a react website, and I need to wait for a request to pass before returning the value. I need to loop it so I can't stack .then(). Why does this code never return the value?

function PlaylistTracks(spotify, id, offset) {
  var r = null;
  spotify.getPlaylistTracks(id, { limit: 100, offset: offset }).then((response) => {
   r = response;
 });

 while (r == null) {
   console.log("Waiting for response");
 }
 return r;
about 4 years ago · Juan Pablo Isaza
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