Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

207
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda