Home > other >  At API I can't access FormData object that I have created At vue js
At API I can't access FormData object that I have created At vue js

Time:12-10

If i send and image only i can access it, but problem is that i need to send some titles, sub titles and text.

My form tag:

<form @submit.prevent="handleFormSubmit" method="POST" enctype="multipart/form-data">

My blog data looks like this:

   blog:{
                postTitle: '',
                sectionTitles:[
                    {
                        sectionTId: 0,
                        title: ''   ,
                        belongsTo: '' 
                    },
                    
                ],
                images: [
                    {
                        // imageId: 0,
                        // belongsTo:''
                    }

                ],
                textareas: [
                    {
                        textareaId:0,
                        text: '',
                        belongsTo:''
                    },

                ]

            },

here is my submit:

async handleFormSubmit(){
    let data = new FormData();
    data.append('blog',this.blog)
    await this.setCreatePost(data)
},

At Laravel I just return request:

return $request['blog'];

And I get:

data: "[object Object]"

CodePudding user response:

data.append('blog',JSON.stringify(this.blog))
  • Related