I was wondering about this too as I'm very new to Archer... and found that promises with continuations and lambdas work very well !
var req = require('request');
var logToLogService = true;
var logServiceUrl = 'http://localhost:8765'
var promise1 = new Promise(function(resolve, reject) {
setTimeout(function() {
resolve('foo');
}, 300);
});
promise1.then((value) => { doLog(value);})
.then(
(val) => { doLog(promise1); }
).then(
() => { doCallbackToArcher(); }
);
function doCallbackToArcher()
{
doLog("Invoking archer callback");
myDataSet = '"vendorid","vendorname"\r\n"v1","Import test vendor 1"\r\n"v2","import test vendor 2"';
//--Invoke the RSAArcher callback to return your data and PreviousRunContext token to RSA Archer.
callback(null, {
//Return the data to RSA Archer
output: myDataSet,
//PreviousRunContext token value; 256 char limit. If omitted, the token is cleared.
previousRunContext: "myContextVariable"
});
doLog("End - Archer interface");
}
function doLog(l)
{
console.log(l);
if (logToLogService)
{
req(`${logServiceUrl}/?l=${encodeURIComponent(l)}`, function (error, response, body) {
});
}
}