функция httpsGet (myData, callback) {
var options = {
host: 'cp6gckjt97.execute-api.us-east-1.amazonaws.com',
port: 80,
path: '/prod/stateresource?usstate=' + encodeURIComponent(myData),
method: 'GET',
};
var req = https.request(options, res => {
res.setEncoding('utf8');
var returnData = "";
res.on('data', chunk => {
returnData = returnData + chunk;
});
res.on('end', () => {
console.log(JSON.stringify(returnData))
var pop = JSON.parse(returnData).population;
callback(pop); // this will execute whatever function the caller defined, with one argument
});
});
req.end();
}