问题
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);
});
回答1:
This is problem with Android 9 or 10, you have to add SSLCertificateChainFile in Apache configuration.
SSLCertificateChainFile "/opt/bitnami/apache2/conf/server-ca.crt"
Then it will be working fine
来源:https://stackoverflow.com/questions/51146430/https-undefined-in-react-native-axios