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

250
Views
¿Hay alguna manera de hacer que el código principal espere una búsqueda anidada?

Estoy trabajando en un bot de Slack que obtiene solicitudes de combinación para una lista dada de repositorios (tan múltiples).

 const fetchRepositories = (repositories) => { return repositories.reduce(async (accumulator, currentRepository) => { const eligibleMRs = await fetchEligibleMergeRequests(currentRepository.api); // the PROBLEM is here const refinedMRs = eligibleMRs.length && eligibleMRs.map(mr => { // some logic to clean the shorten info received } return Promise.resolve(accumulator) .then(...) //return personalized object for each repository }, []); };

El problema es que eligibleMRs es una matriz de Promise { <pending> } (cada solicitud de combinación).

Y este problema apareció cuando, en lugar de solo obtener todas las solicitudes de combinación del repositorio, agregué otro .then que obtiene la lista de revisores para cada mr.

 const fetchEligibleMergeRequests = (url) => { return fetch(url, fetchOptions) .then(response => { return response.json(); }) .then(data => { return data.filter(mr => filterMergeRequest(mr)); // when I only had this .then everything was perfect }) .then(async filteredMRs => { return filteredMRs.map(async mr => { const fetchedReviewers = await fetchReviewers(mr["project_id"], mr.iid); //this fetch is another call to GitlabAPI in order to retrieve reviewers return Object.assign({}, mr, { reviewers: fetchedReviewers }); }); }) };

Para lo que me gustaría pedir ayuda es el hecho de que la búsqueda recién agregada (la que obtiene los revisores para cada señor) parece retrasar todo. Y me gustaría hacer que el código principal ESPERE para que los revisores lo busquen.

Gracias a todos los que intentan ayudar.

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!