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

162
Views
Passing multiple params issue in VUE.JS

I am trying to get data by passing multiple ids as param.But the params i am passing is going as array which i don't want.

Example:

Current data: The api is returning param as details?ids[]=123&ids[]=245

Expected data: I would like to pass the param as details?ids=123&ids=245

  const postRes = await axios.post('employee/departments', this.details);
  const getRes = await axios.get('employee/departments',
     { params: { ids: postRes.map(i=>i.id)},
  });
  this.$emit('fileDetails', getRes.data);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could serialize the parameters yourself:

  1. Map each object into a string, containing 'ids=' prefixed to the object's id.
  2. Join the resulting array with a & delimiter.
const params = postRes.map(i => 'ids=' + i.id) 1️⃣
                      .join('&') 2️⃣
const getRes = await axios.get('employee/departments?' + params)

Run this snippet for example output:

const postRes = [{ id: 11 }, { id: 22 }, { id: 33 }]
const url = 'employee/departments?' + postRes.map(i => 'ids=' + i.id).join('&')
console.log(url)

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!