我将本地服务器用于react-native应用程序,而axios post请求出现问题:
使用这种失眠症时:
一切都很好,我的意思是服务器响应是预期的{ "status":"success" }
。但是,对于axios:
axios
.post('http://192.168.1.41/meeter-from-here/backend/event.php', {
sesionID: '',
eventName: 'UserCreated',
eventData: {
username: 'faaafsdsd',
email: 'bfdsfsbbf@bbb.com',
password: 'ccccccccccc',
},
})
.then(function(response) {
console.log(response.data);
})
.catch(function(error) {
console.log(error);
});
没有response.data。我的问题是axios要求的确切等同于insomia的?我试图对其进行修改,但结果仍然是空的。 (这意味着请求不正确)
答案 0 :(得分:1)
我认为您需要在eventData中包含字符串,请尝试以下操作:
eventData: {
'username': 'faaafsdsd',
'email': 'bfdsfsbbf@bbb.com',
'password': 'ccccccccccc',
},
希望这会有所帮助!