https 在 react native axios 中未定义 [英] https undefined in react native axios

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

问题描述

我已经将 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"

然后它会正常工作

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

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