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

116
Views
Does anyone know why I can't add elements to javascript array?

I am attempting to add url to defiList, but push() doesn't seem to work. When I print out url, it works, but when I print url, the list comes out as empty. See output for the empty defiList array and elements printed out. Any help would be greatly appreciated!

image

const listRef = ref(storage, 'data');
let defiList = new Array();
listAll(listRef).then((res) => {
  res.prefixes.forEach((folderRef) => {
      // You may call listAll() recursively on them.
    });
    res.items.forEach((itemRef) => {
      getDownloadURL(ref(storage, itemRef)).then((url) => {
      defiList.push(url);
// --- .push() won't work, but console.log() does
      console.log(url);
      });
    });
  }).catch((error) => {
    console.log(error);
  });
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!