Why does my edit button in a vue data-table not work? The method creates a new line in the table. I want do edit a line.
template
<!-- DIALOG PARA EDITAR USUARIO -->
<v-dialog v-model="editarDialog">
<v-card>
<v-card-title>
<span class="text-h5">Editar Pessoa</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<v-col cols="12" sm="6" md="4">
<v-text-field
v-model="pessoa.nome"
label="Pessoa*"
required
></v-text-field>
</v-col>
<v-col cols="12" sm="6" md="4">
<v-text-field v-model="pessoa.idade" label="Idade*"></v-text-field>
</v-col>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="editarDialog = false">
Fechar
</v-btn>
<v-btn color="blue darken-1" text @click="editarPessoa"> Salvar </v-btn>
</v-card-actions></v-card
></v-dialog
>
script
function botaoEditarPessoa(item) {
state.pessoa = Object.assign({}, item);
state.dialog = true;
}
async function editarPessoa() {
try {
const res = await axios({
url: "http://localhost:3000/update",
method: "put",
data: state.pessoa,
});
state.pessoa = res.data;
await getData();
state.dialog = false;
} catch (error) {
console.log(error);
}
}
I need to understand why the line ins't being edited. Please, help me find the error