[Vuejs]-How to Send formData through Axios in Vue JS and Node JS?

0👍

Try this code.

import axios from 'axios'

export default () => {
    return axios.create({
        baseURL: "http://localhost:4040",
        credentials: true,
        headers :{
           'Content-Type': undefined
        }
        //WithCredential: true
        //WithCredentials : true
    })
}


 async feedFinalSubmit(){
            const formData = new FormData();
            formData.append("files", this.file);
            formData.append("description", this.thread.description);
            formData.append("pageID", this.$route.params.id);

            const dict = {};
            dict['pageID']=this.$route.params.id;
            dict['description']=this.thread.description;

            const blob = new Blob([dict], {
                        type: 'application/json'
                        });
            formData.append("JsonData", blob); 
            const response = await PageService.threadSubmit(formData);
            if (response.data.success){
               //do somethnig
            }
         }

Leave a comment