Estoy creando un sitio web de reacción y necesito esperar a que se apruebe una solicitud antes de devolver el valor. Necesito hacer un bucle para no poder apilar .then(). ¿Por qué este código nunca devuelve el valor?
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;