I have an application that gets random image and posts it to blog site. But to give a blog site an image it has to have a type of multipart/form-data.
const FormData = require('form-data')
const form = new FormData()
const { data } = await axios.get(
'https://photo-works.net/images/europe-landscape-photo-edited.jpg'
) // image/jpeg
form.append('my-photo', data)
const photo = await axios.post(url, { photo: form }) // that should be multipart/form-data format
You should pass right header information as follows
var formData = new FormData();
formData.append("my-photo", data);
axios.post('upload_file', formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
})