Skip to content

Instantly share code, notes, and snippets.

@eblancoh
Created October 23, 2018 07:37
Show Gist options
  • Save eblancoh/10503ad78e423d817300815b0ecb4a47 to your computer and use it in GitHub Desktop.
Save eblancoh/10503ad78e423d817300815b0ecb4a47 to your computer and use it in GitHub Desktop.
function lucaQuality(payload, cb) {
const options = {
method: "POST",
hostname: '123.456.78.910',
port: '1111',
path: ["/quality"],
headers: {
"Content-Type": 'application/x-www-form-urlencoded',
"Authorization": 'Basic ********'
}
};
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const req = https.request(options, (res) => {
var chunks = [];
res.on("data", (chunk) => {
//console.log('chunk ===>', chunk)
chunks+=chunk;
});
res.on("end", () => {
const body = JSON.parse(chunks);
//console.log('body ====>', body.toString());
cb(null, body);
});
res.on('error', () => {
cb(e, null);
});
});
req.write(qs.stringify(payload));
req.end();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment