The error message "ReferenceError: axios is not defined" means that the axios library is not available in the current scope. To fix this, you need to import the axios library before using it in the watch method.
To import axios, you can add the following line at the top of your script:
import axios from 'axios';
This will import the axios library and make it available in the current scope. Here's the updated code:
import axios from 'axios';
watch: {
date(newDate) {
const showType = document.getElementById('showType');
showType.textContent = newDate;
axios.post('{{ route('product.warranty.save') }}', {
date: newDate,
product_id: this.product_id,
warranty_id: this.warranty_id,
})
.then(response => {
this.dates.push(response.data.date);
this.products.push(response.data.product_id);
this.warranties.push(response.data.warranty_id);
})
.catch(error => {
console.log('Error:', error);
});
},
},
Make sure to install axios using npm or yarn before importing it:
npm install axios
# or
yarn add axios