在本机网络上使用Axios出错

时间:2018-08-31 00:16:53

标签: 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);
  });
}

这是我的info.plist info.plist

为什么会有这个问题?

1 个答案:

答案 0 :(得分:0)

这可能是因为您使用的是http而不是https。

按照下面的讨论,也请尝试关闭所有内容并清除RN缓存。

相关问题