首页 > 解决方案 > TypeError:无法读取未定义的属性(读取“获取”)[react-native-ssl-pinning]

问题描述

我正在构建一个反应原生移动应用程序,我想使用react-native-ssl-pinning实现 SSL 固定。

我已经安装了所有必要的东西,我还导入了 fetch 方法:

import {fetch} from 'react-native-ssl-pinning';

这就是我调用 fetch 方法的方式:

fetch("https://xxx.xxx.xxx.xx/api/account/my_account/", {
  method: "GET",
  headers: {
    Authorization: "Bearer " + token,
    Accept: "application/json; charset=utf-8",
    "Access-Control-Allow-Origin": "*",
    e_platform: "mobile",
  },
  sslPinning: {
    certs: ["mycert"],
  },
})
  .then((response) => response.json())
  .then((responseJson) => {
    console.log(responseJson);
  })
  .catch((error) => {
    console.log(error);
  });

运行应用程序后,我收到此错误:

错误图像

有人有同样的问题吗,或者你有解决方案吗?

非常感谢。

标签: react-nativessl-certificatesslpinning

解决方案


推荐阅读