Below is my code, it is a GET request that will return a Ticket Number (I left the headers/options/auth out).
I want to know why the first console.log below returns a ticket number (as it should), but the second console log does not return a ticket number.
I need to export the ticket number to fire another module. Is there a way to get that ticket number outside of this area? I am stumped.
Thanks in advance.
options.path += orderNumber;
var req = https.request(options, function (res) {
  var chunks = [];
  res.on("data", function (chunk) {
    chunks.push(chunk);
  });
  res.on("end", function () {
    global.body = Buffer.concat(chunks);
    module.exports.cw = JSON.parse(body.toString()).customerOrderNo.replace(/\D/g,'');
    **console.log(module.exports.cw);**
  });  
});
**console.log(module.exports.cw);**
req.write(JSON.stringify({ id: 0,
  description: 'maxLength = 100',
  url: 'Sample string',
  objectId: 0,
  type: 'Sample string',
  level: 'Sample string',
  memberId: 0,
  inactiveFlag: 'false' }));
req.end();
 
     
    