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

99
Views
JavaScript llamando a la función asíncrona al mismo tiempo con diferentes parámetros

Tengo una función asíncrona "getResults" que realiza la búsqueda en espera, espera el resultado y luego hace algo con el resultado.

Si llamo a esa función asíncrona "getResults" con 2 parámetros diferentes al mismo tiempo, queriendo obtener 2 cosas diferentes, seguirá adelante y realizará solo una de ellas (supongo que la que entró primero)

 async function getResults(id, source, destination) { let result1 = await fetch.listen({ listen: id }, apiHost("api.gps.com", "someparam", source)) /* this would be fetch result with parameters from getLosAngelesRoute function */ let result2 = /* here I would like to fetch with parameters from getWashingtonRoute function */ if (result1 !== result2) { // do something } else { // do nothing } } function getLosAngelesRoute() { getResults("id1", "newYork", "losAngeles") } function getWashingtonRoute() { getResults("id2", "detroit", "washington") }

La solución alternativa es tener 2 funciones diferentes "getResultsA" y "getResultsB" y llamarlas por separado...

Pero, ¿es posible llamar a la función "getResults" con diferentes parámetros de las funciones getLosAngelesRoute y getWashingtonRoute al mismo tiempo, hacer que busque, espere AMBOS y luego haga algo con ambos resultados, todo dentro de una función?

Espero que esto tenga sentido.

Gracias por sus valiosos pensamientos.

about 4 years ago · Santiago Gelvez
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!