ios - 在 react-native 网络错误上使用 Axios 时出错
问题描述
我在我的代码中使用 Axios,当我尝试为 API 发送数据时,在控制台中出现一条消息“错误网络错误”
这是我的代码:
salvar() {
axios.post('http://easypasse.com.br/gestao/wsCadastrar.php',
{ nome: this.state.nome, cpf: this.state.cpf, senha: this.state.senha, method: 'app-set-usuario', "plataforma": 'ios'},
{headers: {'Content-Type': 'application/json'}
})
.then(function(response){
console.log(response)
})
.catch(function(error) {
console.log('Erro ' + error.message);
});
}
为什么会出现这个问题?
解决方案
这可能是因为您使用的是 http 而不是 https。
根据下面的讨论,还可以尝试关闭所有内容并清除 RN 缓存。
推荐阅读
- android - 如何显示可调用云函数的错误?
- python - python pandas:我在使用 drop 函数的行中出现错误
- android - AlertDialog.dismiss() 不同步
- sql - 使用 Where 子句在一个字段中更新大量数据
- c# - 从json延迟加载gridview
- java - 如何通过 netbeans 启用从窗口机器到 Ubuntu 机器的远程调试
- r - 从图中的“基线”中找到增加,不知道该怎么做
- javascript - 从对象数组 JavaScript 创建单个对象
- python - 如何使用 scipy.optimize.fmin_l_bfgs_b 拟合递归关系?
- angular - 角度项目中 .angulardoc.json 文件的用途是什么?