var formData = new FormData();
var imagefile = document.querySelector('#file');
formData.append("image", imagefile.files[0]);
axios.post('upload_file', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})
axios.get('data.json')
.then(res => console.log(res.data))
.catch(err => console.log(err)
const photoFormData = new FormData();
// dict of all elements
photoFormData.append("avatar", file);
photoFormData.append("email", this.state.email);
photoFormData.append("name", this.state.name);
let headers = {
Authorization: "token",
'Content-Type':'multipart/form-data'
};
let formData = new FormData();
for(let key in files){
formData.append('files[][file]', files[key].file, files[key].file.name)
formData.append('files[][file_type_id]', files[key].fileType)
}
axios
.post(
"/api/files",
formData,
{ headers }
)
.then(()=>{console.log('It Works')})