我正在向服务器发出POST请求,以上传图像并在react-native中使用axios发送formdata。我收到“网络错误”。我也尝试获取,但没有任何工作。在postman api中,使用react本地图像选择器libeary选择图片。
formData.append('title', Title);
formData.append('class_id', selectClass._id)
formData.append('subject_id', checkSelected)
formData.append('teacher_id', userId)
formData.append('description', lecture);
formData.append('type', 'image');
var arr=[];
arr.push(imageSource)
arr.map((file,index)=>{
formData.append('file',{
uri:file.path,
type:file.type,
name:file.name
})
})
axios({
method: 'post',
url: URL + 'admin/assignment/create',
data: data,
headers: {
"content-type": "multipart/form-data",
'x-auth-token': token,
},
})
.then(function (response) {
//handle success
console.log('axios assigment post',response);
})
.catch(function (response) {
//handle error
console.log('axios assigment post',response);
});
我正在向服务器发出POST请求,以上传图像并在react-native中使用axios发送formdata。我收到“网络错误”。我也尝试获取但无济于事。使用react native image ...
“ react-native”:“ 0.62.1”,“ react”:“ 16.11.0”,“ axios”:“ ^ 0.19.2”,