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

105
Views
Javascript - Returning a variable and a promise from a map function

I am trying to return a variable and another promise from within a promise:

aPromise(url)
    .then((response) => {
        return Promise.all(
        response.map((response) => {
            return {id: response.id, response: aPromise(response.url)};
        }
     })
     .then((data) => {
         // do something with data.id and data.response}
     }

In this example data.id is accessible but the promise data.response has not resolved. however if I return only the apiRequest(response.url) promise from the .map() then it does resolve. the output of data should match =

[
    {id:'123', response: {...},
    {id:'456', response: {...},
    ...
]
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!