Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

119
Vistas
Pass second param when map urls with axios.all

i have a array that contains a object with two values, like this:

[
 {
  brand: app1,  
  url: https://myhost.com/api
 },
 {
  brand: app2,  
  url: https://otherapi.com/api
 }
]

I'am using axios.all to made a get request over all urls, and I iterate it with a map, like this:

const getData= axios.all(stuffData.map((item) => axios.get(item.url)))
.then(res => console.log(res.data)

The thing is, how can I pass the second param in the array when i make the map to interate all axios requests? I also need pass the key "brand".

Thanks

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Use this:

Promise.all(stuffData.map(async (item) => ({ 
  data: await axios.get(item.url).data, 
  brand: item.brand
}))).then((data) => {
   data.forEach(item=> console.log(item))
})
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda