2 months ago

Form dosen't submit all data

Posted 2 months ago by hjortur17

I have a method that uses Axios to post a form but I'm trying to use a computed prop in that method but it isn't picking it up.

This is the error:

General error: 1364 Field 'dates' doesn't have a default value (SQL: insert into `booking`

Here is the script:

    import axios from 'axios';
    import kennitala from 'kennitala';
    import moment from 'moment';
    import payment from './Payment.vue';

    export default {
        components: { payment },

        data() {
            return {
                errors: [],
                services: [],
                selectedValue: null,
                step: 1,
                    carNumber: null,
                    carSize: "Bíltegund",
                    carType: null,
                    carSubtype: null,
                    carColor: null,

                    name: null,
                    socialId: null,
                    email: null,
                    phone: null,

                    dropOffDate: null,
                    dropOffTime: "Hvenær mættiru á Leifstöð",
                    pickUpDate: null,
                    pickUpTime: "Hvenær viltu sækja bílinn?",
                    flightNumber: null,
                discount: null,
                showPayment: false,
                price: 4500,

                start: null,
                end: null

        methods: {
            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, "MM/DD/YYYY"),
                    dropOffTime: this.booking.dropOffTime,
                    pickUpDate: moment(this.selectedValue.end, "MM/DD/YYYY"),
                    pickUpTime: this.booking.pickUpTime,
                    flightNumber: this.booking.flightNumber,

                    dates: this.numberOfDays,
                    priceForDays: this.priceForDays,

                    totalPrice: this.price,
                    finalPrice: 100
                .catch(error => {
                .then(function (response) {})

        computed: {
            numberOfDays: function() {
                this.start = moment(this.selectedValue.start);
                this.end = moment(this.selectedValue.end);

                return Math.abs(this.start.diff(this.end, 'days'));

Please sign in or create an account to participate in this conversation.