https undefined in react native axios

China☆狼群 提交于 2021-02-18 07:45:08

问题


I have used axios for react native app but while implementing https.agent it shows https is undefined. How to solve this?
My code

const instance = axios.create({
  httpsAgent: new https.Agent({
    rejectUnauthorized: false
  })
});

 instance.get('https://example.com');

// At request level
const agent = new https.Agent({
  rejectUnauthorized: false
});
    axios.post('/practz/login', {
          "username" :"orgadmin1@example.com",
          "password":"exam",
          "appId":"AABBCD",
          "domainName":"example.com",
          httpsAgent: agent
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });

回答1:


This is problem with Android 9 or 10, you have to add SSLCertificateChainFile in Apache configuration.

SSLCertificateChainFile "/opt/bitnami/apache2/conf/server-ca.crt"

Then it will be working fine



来源:https://stackoverflow.com/questions/51146430/https-undefined-in-react-native-axios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!