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

165
Views
Necesito llamar a api dentro de forEach y obtener esas respuestas en una matriz y regresar. Pero regresa como una matriz vacía en js (javascript)

Aquí está mi código y el idioma es javascript.

 return new Promise(async (resolve, reject) => { let responses= await axios.get("https://api.surveymonkey.com/v3/surveys/"+id+"/responses/bulk", { headers: { 'Authorization':config } }) resolve(responses.data) }); } responses_by_nicknames=async(nicknames)=>{ return new Promise(async (resolve, reject) => { _.forEach(nicknames, function(value) { let responses_by_nicknames2=[] let obj ={"nickname":value.nickname} console.log(value) _.forEach(value.surveys,async function(value2) { Promise.all([responses_by_id(value2.id)]). then(body => { responses_by_nicknames2.push(res) }) }) console.log("!!@@",responses_by_nicknames2) }) resolve(responses_by_nicknames) }) }

Console.log también proporciona una matriz vacía. Según entendí, el registro de la consola y la "resolución" se ejecutan antes de llamar a la API.

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!