1 year ago

ReferenceError: axios is not defined

Posted 1 year ago by Shiva

I'm getting this error when I try to submit a form using vue

ReferenceError: axios is not defined

I don't know why this is happening. Isn't axios already imported in the bootstrap.js that's in the resources/js/ folder?

Here is my vue file

    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card">
                    <div class="card-header">Example Component</div>

                    <div class="card-body">
                        I'm an Supplier Code Selection component.
                        <form @submit.prevent="submit">
                            <label for="parent-product">Parent Product</label>
                            <select name="parent-product" id="parent-product" class="form-control" v-model="selected_parent">
                                <option>Please select your code</option>
                                <option v-for="product in products" :value="">
                                    {{ product.supplier_code }}

                                    <option v-for="child in children" :value="">
                                        {{ child.supplier_code }}

                            <input type="submit" class="btn btn-primary" value="Submit">

    export default {
        props: [

        mounted() {
            console.log('Component mounted.')

        methods: {
                var formData = new FormData();

                console.log('this is the select box - '+this.selected_parent);
                formData.append('parent-product', this.selected_parent);

                return'/add-to-cart/'+this.selected_parent, formData);

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