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;
