How do I get a variable out of an async function?
I have the following and I'd like to get the httpsResp variable from this async function.
var httpsResp;
var dfd = this.async(10000);
var httpsReq = https.request(httpOptions, dfd.callback(function (resp) {
httpsResp = resp.statusCode;
assert.strictEqual(httpsResp, correctResp, error.incorrectResp);
}), dfd.reject.bind(dfd));
httpsReq.end();
httpsReq.on('error', function(e) {
console.error(e);
});
console.info('Status Code: ' + httpsResp);
Currently, httpsResp shows undefined.