diff --git a/pages/editar/productos/index.vue b/pages/editar/productos/index.vue index 9b97fb4..1c221fa 100644 --- a/pages/editar/productos/index.vue +++ b/pages/editar/productos/index.vue @@ -15,10 +15,10 @@ - -
@@ -160,9 +160,27 @@ export default { async deleteItem(item) { if (confirm('Confirma que quieres eliminar este producto')) { - await this.$api.delete(`/my_products/${item.item.id}`) - const index = this.products.indexOf(item.item) - this.products.splice(index, 1) + const config = useRuntimeConfig() + try { + await $fetch(`/my_products/${item.item.id}`, { + baseURL: config.public.baseURL, + method: 'DELETE', + headers: { + Authorization: `Bearer ${this.auth.access}`, + }, + }) + const index = this.products.indexOf(item.item) + this.products.splice(index, 1) + this.selectedItemsIndexes = [] + this.modalText = 'Los productos han sido eliminados correctamente.' + this.modalColor = 'success' + this.activeModal = true + } catch (error) { + console.error(error) + this.modalText = 'Ha habido un error' + this.modalColor = 'danger' + this.activeModal = true + } } },