Form data sends empty request to the server

188 Views Asked by At

I am using vuejs and laravel to make a panel for admin I understand i can not send any files without form data so i gotta use formData like this

onSubmit(evt) {
                evt.preventDefault();

                this.emptyValidator();

                let data = new FormData();
                console.debug(this.form)
                for (let input in this.form) {
                    data.append(input, this.form[input]);
                }
                data.append('image', this.image);
                console.debug(data)
                console.debug(this.image)
                ProductDataService.update(this.id, data)
                    .then(response => {
                        let data = response.data;
                        if (data.data) {
                            Swal.fire('edited successfully', '', 'success');
                        }
                    })
                    .catch(error => {
                        if (error.response.status && error.response.status === 422)
                            this.handleValidation(error);
                    })

            },

Note: i am using it in production mode

and when i try to dd in laravel it shows me empty

i did not have any problem with sending manual and formData in edit is a pain in my ass

as u can see formData.entries works fine

0

There are 0 best solutions below