2016-09-22 72 views
0

由于某些原因,使用React Native作为POST发送实际Android设备的请求时,服务器仅接收GET请求。有人可以解释为什么会发生这种情况,以及如何防止协议切换?我在某处阅读指定HEADERS将有助于解决此问题,但这不是事实。有没有其他人也经历过这种异常?阻止React Native将POST更改为GET请求

addTask = async (title, imgFile) => { 

var formData = new FormData(); 
formData.append("json", JSON.stringify({ title: title, status: "New", priority: "Normal" })); 
axios.request({ 
    url: API_URL + 'tasks', 
    method: 'post', 
    data: formData, 
    headers: { 
    'Accept': 'application/json', 
    'Content-Type': 'application/json' 
    } 
}).then(response => { 
    console.log('response', response); 
}); 
} 

回答

0

显然POST请求需要使用HTTPS而不是http ... 我发现结果从StackOverflow - 34570193

我不记得遇到任何网络错误,这是为什么我从来没有看着这张贴在第一个地方。希望这有助于某人。