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

187
Vistas
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 Respuestas
Responde la pregunta

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