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

256
Views
axios multipe param request

I'm trying to make a query with axios and parameters When I perform this code:

axios.get('/myApi', { params: { id: [1,2,3] })

This puts all in the same url

http://localhost/api/myApi?id[]=1&id[]=2&id[]=3

Is there a possibility that I will get a different request each time knowing that my input table will be dynamic?

I would like this dynamically:

http://localhost/api/myApi?id[]=1
http://localhost/api/myApi?id[]=3
http://localhost/api/myApi?id[]=3
...

thanks in advance

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

No but you can loop through that url params and request it using axios like :-

for (let i = 0; i < id.length; i++) {
  axios.get('/myApi', { params: { id: [i] })
}
about 4 years ago · Juan Pablo Isaza Report

0

No you have to do that yourself, by issuing multpile requests.

You can utelize Promise.all and map for that.

map is used to issue the individual requests for the passed ids, and to store the Promises returned by axios in an array. And Promise.all to wait for all of them to resolve.

function batchRequest(ids) {
   return Promise.all(ids.map( id => {
      return axios.get('/myApi', { params: { id: [id] }})
   }))
}

about 4 years ago · Juan Pablo Isaza 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!