Answer the question
In order to leave comments, you need to log in
How to make an https request?
var HttpsProxyAgent = require('https-proxy-agent');
var request = require('request');
var sslRootCAs = require('ssl-root-cas/latest')
sslRootCAs.inject()
var proxy = 'http://192.168.1.243:8888';
var agent = new HttpsProxyAgent(proxy);
request({
uri: "https://vk.com",
method: "POST",
headers: {
'content-type': 'application/x-www-form-urlencoded'
},
agent: agent,
timeout: 10000,
followRedirect: true,
maxRedirects: 10,
body: "name=john"
}, function(error, response, body) {
console.log("Error" + error);
console.log("Response: " + response);
console.log("Body: " + body);
});
ErrorError: unable to verify the first certificate
Response: undefined
Body: undefined
Answer the question
In order to leave comments, you need to log in
Why do you need an agent? and what are you trying to achieve?
const https = require('https');
var options = {
hostname: 'vk.com',
path: '/',
method: 'POST'
};
var req = https.request(options, (res) => {
console.log('statusCode: ', res.statusCode);
console.log('headers: ', res.headers);
res.on('data', (d) => {
});
});
req.end();
req.on('error', (e) => {
console.error(e);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question