NodeJS: HTTP Request - Response
Sending HTTP GET/POST Request and Response using Node JS.
Code:
Code:
var https = require("https"); exports.handler = (events,context,callback) => { var options = { host : 'hostname', port : '443', path : 'ifany', headers: { 'Authorization' : 'Basic' + new Buffer("username" + ':' + "password").toString('base64') } }; // request request = https.get(options, function(res){ var body = ""; res.on('data', function(data){ body = body+data; }); res.on('end', function(){ // response Response = JSON.parse(body); console.log(Resposne); }); callback(null,{ "dialogAction":{ "type": "close", "fullfillmentState":"Fullfilled", "message":{ "contentType":"PlainText", "content" : "Thank You! A email has been sent." } } }); }); };
Comments
Post a Comment