如何在 axios post 请求中设置标头?我不断收到 Multipart:Boundary not found (React Native)
我尝试将边界设置为任意数字,但仍然不起作用。- '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 …Run Code Online (Sandbox Code Playgroud)