代码之家  ›  专栏  ›  技术社区  ›  Nitesh

从少数特定的Android设备调用React Native中的API时出现网络错误

  •  0
  • Nitesh  · 技术社区  · 4 年前

    我们集成了一个非常简单的测试apk,该测试apk将运行在IIS上的HTTPS API调用到react本机应用程序中。问题是,当试图从运行Android 7的摩托罗拉C Plus手机进行API调用时,它抛出了“网络错误”;三星Galaxy J2。

    示例代码

     var dataToSend = {
          Name: name,
          Email: userEmail,
          Password: password,
          Mobile: mobile,
        };
    
    try {
      alert('Entered inside of try block');
      const userRes = await axios.post(
        'https://api.in/api/Account/CustomerRegistration',
        dataToSend,
      );
      
    //Code does not display this alert
          alert('after axios request');
          alert(JSON.stringify(userRes.data));
        } catch (error) {
          alert(error); // request failed with status code 400
          console.log('error', error);
        }
    

    该应用程序在本地主机和其他安卓手机上运行良好。已经测试了SSL证书,看起来还可以。对这个问题一无所知。如有任何帮助,我们将不胜感激。如果需要,很乐意分享代码。

    0 回复  |  直到 4 年前
    推荐文章