4

I'm trying to make an API call to a https:// resource using Axios inside React Native.

I'm making the call as follows:

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


        instance.get('https://foodspecials-api.local/api/v1/specials/2')
            .then((response) => {
                console.log('WORKED');
                console.log(response);
            })
            .catch((e) => {
                console.log('FAILED');
                console.log(e);
            });

This, however, results in an error message ReferenceError: Can't find variable: https

I've created a SSL certificate which is self-signed.

Is there a workaround for this?

Marcus Christiansen
  • 3,017
  • 7
  • 49
  • 86

1 Answers1

1

https module is for nodejs (does not work with react-native)

puckj
  • 11
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 01 '22 at 04:42