1

I am trying to submit an object that has formData inside of it

 data() {
     return {
         card: this.initializeCardObject(),
     }
},
initializeCardObject() {
     return {
         blurb: null,
         thumbImagePath: null,
         collection_id: this.collection.id,
         image: new FormData(),
      }
},

However when I submit it

methods: {
    async saveCard(image) {
         this.card.image.append('thumbnail', image);
         await axios({
             method: "post",
             url: "/cards",
             data: this.card,
             headers: { "Content-Type": "multipart/form-data" },
         })
         .then( res => {
             console.log(res.data);
         })
     }

It gives me the error Missing boundary in multipart/form-data POST data. If I don't add the headers it submits to my controller but the formData has been turned into an array with no data. How do I send the image?

Chris Grim
  • 149
  • 1
  • 6
  • 20

0 Answers0