1
votes

I have some problems to run my app, I try to disable the SSL configuration from fetch methods, but no success yet. Here bellow some code:

const fetch = require('node-fetch');
        const https = require('https');  <--- Here
        const httpsAgent = new 
        https.Agent({ rejectUnauthorized: false});
        var username = this.state.username;
        var password = this.state.password;
          if (username && password) {
            fetch("https://...url here...", {
              method: "POST",
              headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',

follow error is:

You attempted attempted to import the Node standard library module "https" from "components\Login.js". It failed because React Native does not include the Node standard library. Read more at https://docs.expo.io/versions/latest/introduction/faq/#can-i-use-nodejs-packages-with-expo ERROR 12:37 Building JavaScript bundle: error

1

1 Answers

0
votes

Node-fetch is for nodeJs not react native.. use npm react-native-fetch https://www.npmjs.com/package/react-native-fetch or personally I would use axios https://www.npmjs.com/package/react-native-axios