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

189
Views
axios get string and patch as object from the same input vue 3

I have a table that I get the userList as props and render it into the table with v-for="(user , index) in userList" :key="index" and as string :value="user.username" but now my swagger API needs me to patch it as an object of s.th like username:{value: "", operand: 1} does anyone know how am I supposed to change the data type and send it as formData to my axios patch? my axios.patch was also like this before i find out I need an object to pass :')

async userEdit(id) {
      const response = await this.$store.dispatch('axiosPatch', {url: `/employees/${id}`,
        formData: {
          username: this.username.value,
          email: this.email,
          mobile: this.mobile,
        }
    }, this.$data)
   },

my input form is also like this:

<input type="text" class="text-xs text-secondary mb-0 text-center
                  border-0 bg-white w-100 p-1"
        :disabled="!user.disabled"
        :value="user.nationalCode">
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could declare an object variable in the data part and then assign items to it for example we have items object defined in data then we have items.username,items.email, and so on, at the end when you want to send this object to the server, you could convert all of these by doing a for loop on it. for example:

let dataToPatch = [];
let items = {username:'Ali',email:'test@test.com'};
for(item in items){
  const newItem = {};
  newItem[item] ={value:items[item],operand: 1};
  dataToPatch.push(newItem);
}

console.log(dataToPatch)

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!