0

I am trying to upload a file to a rest api using vanilla javascript (Form data). I dont know what i am doing wrong but i get the following error

Cannot read property 'call' of undefined at new FormData

this is my code:

var url = "http://127.0.0.1:8000/api-gaugeStore/GaugeAttachmentsSerializersSerializersAPIView/"
let formData = new FormData();
formData.append('file', this.file);
console.log('>> formData >> ', formData);


axios.post(url,
    formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    }
    ).then(function () {
        console.log('SUCCESS!!');
    })
    .catch(function () {
        console.log('FAILURE!!');
    });
}
heretolearn
  • 6,047
  • 4
  • 29
  • 52
Mphoza
  • 107
  • 2
  • 5

0 Answers0