0

In my vuejs project, I need to send the image file in binary form, but when I try this way, the image always comes up blank. The backend has an endpoint that only accepts images and works with multipart/form-data. Where do you think I go wrong, I'm waiting for your ideas.

endpoint expects a payload like form data: file: (binary) from me

Request Payload
{data: {image: {}}}
data: {image: {}}
image: {}

template:
            <v-file-input
                      v-model="image"
                      color="#F65C38"
                      counter
                      label="File input"
                      multiple
                      placeholder="Select your files"
                      prepend-icon="mdi-paperclip"
                      outlined
                      :show-size="700"
                    >

Data:

    image:null 



script:

    axios
    .post(
      'example/images/upload',
      {
        data: {
          image: this.image,
        },
      },

      {
        headers: {
          Authorization: `Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImNoZ3VuYXkzQGdtYWlsLmNvbSIsImlkIjoxLCJ0eXBlIjoxLCJpYXQiOjE2NDU0NDUxMjR9.Kg8NcFiAKtBHxkQsRwl2pO6svcxvxvp7SDQSQw13SJ4xe1vc`,
          'Content-Type': 'multipart/form-data',
        },
      }
    )
VLAZ
  • 26,331
  • 9
  • 49
  • 67

0 Answers0