在React Native Axios中未定义的https [英] https undefined in react native axios

查看:61
本文介绍了在React Native Axios中未定义的https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用axios来响应本机应用程序,但是在实现https.agent时,它显示https是未定义的.该怎么解决?
我的代码

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);
      });

推荐答案

这是Android 9或10的问题,您必须在Apache配置中添加SSLCertificateChainFile.

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

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

然后它将正常工作

这篇关于在React Native Axios中未定义的https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆