Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda