【发布时间】:2020-10-08 19:44:55
【问题描述】:
我正在尝试使用 axios 向我服务器上的 WebApi 发送一个 Post 请求,使用 PostMan 测试 API,API 接受并正常工作。
但在我的 React Native App 上,当我发送 axios.post 时,它返回“错误:请求失败,状态码 415”。
当我用 postData Returns Error:Network Error 发送帖子时,什么时候
我按照下面的方式发送它返回Error 415。
我进行了很多搜索,但无法解决这个问题。有人可以帮忙吗? 贝娄是我的 js 代码。
let postData = new FormData();
postData.append('file',{ uri: response.uri });
postData.append('auditid',auditID);
//axios.post("http://172.16.0.10:8081/api/auditpicture/", postData,{
axios.post("http://172.16.0.10:8081/api/auditpicture/",{
headers: {
"Content-Type": 'multipart/form-data; boundary=${formData._boundary}',
}
,
body:
[{
file:response.uri,
auditid:auditID
}]
}).then(response=> {
console.log(response.data)
}).catch(error=>{
console.log(error);
})
【问题讨论】:
标签: reactjs react-native post axios