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

116
Views
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 answers
Answer question

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 Report
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!