[Solved] node.js request Error: Error: unable to verify the first certificate

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

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *