Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!