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

206
Vistas
why is my `lyrics` variable returning an empty string outside async/await function

i made a request to an api it returns an object it has property holding a string i stored the string in a variable named lyrics now if i console log the variable inside the async await function it gives the string but if i console.log the variable outside of async/ await it returns an empty string which is the value of the variable before i assigned the value of the property to it from the object

let lyrics='';
async function displayLyrics2(url){ 
const request = await fetch(url);
   const response= await request.json();
   console.log(response)
   lyrics+= response.result.lyrics;
   console.log(lyrics);
   }
displayLyrics2()
console.log(lyrics)
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