node.js 中使用 request发起请求时报 Error: unable to verify the first certificate

解决办法
安装 request-promise
const request = require('request-promise');
var options = {
method: 'POST',
uri: 'http://api.posttestserver.com/post',
"rejectUnauthorized": false,
body: {
some: 'payload'
},
json: true // Automatically stringifies the body to JSON
};
rp(options)
.then(function (parsedBody) {
// POST succeeded...
})
.catch(function (err) {
// POST failed...
});
重点是加上 "rejectUnauthorized": false 即可

浙公网安备 33010602011771号