[Vuejs]-Invalid argument supplied for foreach() vue js in laravel

0👍

First thing first. Axios parameters are not correctly passed. Axios expects first parameter as route path, second the form data and third is header. Therefor just modify your axios code like below and it will work.

 const config= {
           headers:{
                    "Content-Type": "multipart/form-data"
                   } 
        }
    this.imageForm.append('product_name',this.product_name);
    this.imageForm.append('product_color',this.product_color);

    axios.post('/save-product',this.imageForm,config).then((response)=>{
              toastr.success('Product Info Added Successfully','Success!');
            }).catch((error)=>{

            })
   

I also attached the laravel response image to show that it is working fine.
enter image description here

Leave a comment