Created
October 23, 2018 07:37
-
-
Save eblancoh/10503ad78e423d817300815b0ecb4a47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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