cancel
Showing results for 
Search instead for 
Did you mean: 

JavaScript Data feeds

jsol5
Advocate II

Anyone that's doing JS Data Feeds.

Curious if you're doing any "chaining" or "promises"  or something else to handle multiple dependent async calls.

2 REPLIES 2

EricDonoho
Contributor II

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) {
});
}
}

 

Anonymous
Not applicable

Very cool, Eric Donoho!

 

Client never cease to impress me with their creative uses of the product. This is no exception! Check it out, Jason Solar‌.