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

122
Views
Local variable isn't updating using within ```Promise.all``` function
async policies() {
    let objects = [];
    try {
      const orderList: any = await this.orderRepository.getAllOrders();
      const val: any = orderList.orders.map(async (order: any) => {
      const res: any = await this.policyRepository.getPolicies(helper.sliceOrderId(order.name));
      return res;
    });
    Promise.all(val).then((obj: any) => {
      objects = [...objects, ...obj.items];
      // console.log('dcc', obj);
    });

    return objects;
  } catch (er) {
    return this.errorResolver.resolve(er);
  }
}

In this function I'm getting orders and calling another function with the value, I am calling another function to retrieve all policies. When I did use from Promise.all function. I wanted to store the values to the local variable in the objects variable. but still, it's showing an empty array eventually. I don't know why the data isn't updating.

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!