Express FormData发布在API上,客户端仍然得到;网络错误“;在axios中上载文件时
我正在尝试将图像文件上载到使用multer文件的Express API。 邮递员工作正常。Axios发布数据,但发送网络错误 -createError中的node_modules/axios/lib/core/createError.js:16:24 -handleError中的node_modules/axios/lib/adapters/xhr.js:87:25 - ... 9个来自框架内部的堆栈框架 获取并给出错误Express FormData发布在API上,客户端仍然得到;网络错误“;在axios中上载文件时,express,react-native,axios,expo,multer,Express,React Native,Axios,Expo,Multer,我正在尝试将图像文件上载到使用multer文件的Express API。 邮递员工作正常。Axios发布数据,但发送网络错误 -createError中的node_modules/axios/lib/core/createError.js:16:24 -handleError中的node_modules/axios/lib/adapters/xhr.js:87:25 - ... 9个来自框架内部的堆栈框架 获取并给出错误 handleChange(value) { this.setSta
handleChange(value) {
this.setState({value});
}
async handleSubmit() {
const date = this.state.chosenDate
const value = this._form.getValue();
var imageName = this.state.imageData.split('/').pop(-1)
var image = {
uri : this.state.imageData,
type : 'image/jpeg' ,
name : imageName
}
const body = { ...value , date : date, image : image}
var formData = new FormData();
for(var name in body) {
formData.append (name, body[name]);
}
console.log(formData)
const url = IP + '/dummy'
axios({
method: 'post',
url: url,
data: formData,
config: { headers: {'Content-Type': 'multipart/form-data' }}
})
.then(function (response) {
//handle success
console.log(response);
})
.catch(function (response) {
//handle error
console.log(response);
});
}
我用的是Expo的React Native你找到解决方案了吗?我用的是Expo的React Native你找到解决方案了吗?