I have a
<select id="ddlTipoUsuario" class="form-control" >
<option v-for="tipoUsuario in tipoUsuarios">{{tipoUsuario.Tipo}}</option>
</select>
populated with Vue and axios, but I need to obtain the ID Value to post in another table. In the response.data returns these values:
[ {
"TipoUsuarioId": 1,
"Tipo": "Administrador"
},
{
"TipoUsuarioId": 2,
"Tipo": "Usuario"
} ]
To populate my <select>
i use this code:
export default {
data() {
return {
tipoUsuarios:[],
}
},
method: {
getTipoUsuario() {
axios.get("http://localhost:50995/api/GetTipoUsuario")
.then(response => {
this.tipoUsuarios = response.data,
this.status = response.data
})
.catch(e => {
console.log(e)
})
}
}
This is my POST method for now:
addUsuario() {
axios.post("http://localhost:50995/api/PostUsuario", {
"Nombre": this.nombre,
"ApellidoP": this.apellidoP,
"ApellidoM": this.apellidoM,
"Email": this.email,
"NombreUsuario": this.nombreUsuario,
"Contrasena": this.password
})
},
I need to generate a POST with the value of the ID when i select one option of the <select>
.
Thank You.