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);
});
}