Solution:
Install 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...
});
The point is to add: “rejectUnauthorized”: false