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

196
Views
Javscript printing empty array despite pushing values to it

This code just grabs data from a dynamo table and I'm trying to use the data in something like react. However, it's just returning an empty array when I try to use it. I removed my access key and parameters for this question to be more readable but when I have it in it works to get the data.

let array_tickets = [];

function getTickets(holder_array) {
    docClient.scan(params).eachPage((err, data, done) => {
        if (data != null) {
            for (let index = 0; index < data.Items.length; index++) {
                const element = data.Items[index];
                //console.log(array_tickets.length);
                array_tickets.push(element);
            }
        }
        done();
    });
    return array_tickets;
}

console.log(getTickets());
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!