async function getConfigFromCF()

in resources/module_3_2/request/index.js [28:46]


async function getConfigFromCF(distributionDomainName) {
  let dataString = '';
  const response = await new Promise((resolve, reject) => {
    const req = https.get('https://' + distributionDomainName + '/config/ab_testing_config.json', function (res) {
      res.on('data', chunk => {
        dataString += chunk;
      });
      res.on('end', () => {
        resolve(JSON.parse(dataString));
      });
    });

    req.on('error', (e) => {
      reject(undefined);
    });
  });

  return response;
}