【发布时间】:2018-12-11 06:53:21
【问题描述】:
我已经将 axios 用于 react native 应用程序,但是在实现 https.agent 时它显示 https 是未定义的。如何解决这个问题?
我的代码
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);
});
【问题讨论】:
-
你导入了 'https',
const https = require('https');吗? -
是的,没有找到 https
-
好的,你安装了吗。
$ npm install https? -
是的,我已经安装了
标签: reactjs react-native https axios