I'm trying to create a post method for my booking system. I'm using a computed prop to calculate the number of dates, which I'm using in a few places. When I post this form I get a General error: 1364 Field 'numberOfDays' doesn't have a default value (SQL: insert into `booki into my .log file. Any idea how to pass this prop into this post request.
Here is my post method:
createBooking() {
axios.post('/api/booking/create', {
carNumber: this.booking.carNumber,
carSize: this.booking.carSize,
carType: this.booking.carType,
carSubtype: this.booking.carSubtype,
carColor: this.booking.carColor,
name: this.booking.name,
socialId: this.booking.socialId,
email: this.booking.email,
phone: this.booking.phone,
dropOffDate: moment(this.selectedValue.start).format('DD/MM/YYYY'),
pickUpDate: moment(this.selectedValue.end).format('DD/MM/YYYY'),
dropOffTime: this.booking.dropOffTime,
pickUpTime: this.booking.pickUpTime,
flightNumber: this.booking.flightNumber,
numberOfDays: this.numberOfDays,
priceForDays: this.priceForDays,
totalPrice: this.total,
finalPrice: 100
})
.catch(error => {
error.response.data;
})
.then(function (response) {})
},
And here is the computed method:
numberOfDays: function () {
return Math.abs(moment(this.selectedValue.start).diff(moment(this.selectedValue.end), 'days'))
},