How do I set headers in axios post request ? I keep getting Multipart:Boundary not found (React Native)
I have tried setting the boundary as an arbitrary number like so but that still doesn't work. - 'Content-Type': 'multipart/form-data; boundary=--hadhba122--'
import axios from 'axios'
### upload image section ###
const uploadImage = async (uri: string) => {
let fileType = uri.substring(uri.lastIndexOf('.') + 1)
const baseUrl = 'localurl'
const formData = new FormData()
const imageJSON = {
uri,
type: `image/${fileType}`,
name: `photo.${fileType}`,
}
formData.append('image', imageJSON)
const config = {
headers: {
'Content-Type': 'multipart/form-data;',
},
data: formData,
}
return await axios
.post(baseUrl, formData, config)
.then((result) => {
console.log('i am the result status', result.status)
console.log(result)
})
.catch(console.error)
}