Feat: Create Customer Post API
This commit is contained in:
parent
18df5742d5
commit
c2e91328fb
@ -10,6 +10,11 @@
|
|||||||
v-model="customer.name"
|
v-model="customer.name"
|
||||||
label="Nombre"
|
label="Nombre"
|
||||||
:rules="[rules.required]"
|
:rules="[rules.required]"
|
||||||
|
></v-text-field>
|
||||||
|
<v-text-field
|
||||||
|
v-model="customer.address"
|
||||||
|
label="Direccion"
|
||||||
|
:rules="[rules.required]"
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
@ -63,11 +68,27 @@
|
|||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
},
|
},
|
||||||
submitForm() {
|
async submitForm() {
|
||||||
if (this.$refs.form.validate()) {
|
if (this.$refs.form.validate()) {
|
||||||
// Aquí puedes manejar el envío del formulario
|
try {
|
||||||
console.log('Cliente guardado:', this.customer);
|
console.log(this.customer)
|
||||||
|
const response = await fetch('/don_confiao/api/customers/', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(this.customer),
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
console.log('Cliente Guardado:', data);
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
|
} else {
|
||||||
|
console.error('Error al Crear el Cliente:', response.statusText);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error de red:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
resetForm() {
|
resetForm() {
|
||||||
|
Loading…
Reference in New Issue
Block a user