Tuesday 7 November 2017

How do I put this API call in an 'async.each'?

I'm complete shit at NodeJS. A noob. I've been using RapidMiner for API calls but it's even more frustrating....Can you wrap this in async.each properly for me? It's for my master's thesis on media bias! Just connect the input array urls to the source: in rapid.call !!var array = fs.readFileSync('Kairos.js', 'utf8').toString().split("\n");> async.each (array, rapid.call ?!?!, console.log ??!?!) {setTimeout(function() {rapid.call('KairosAPI', 'createEmotionalAnalysis', {'source': array[i], }).on('success', (payload)=>{ console.log(array[i]); console.log(JSON.stringify(payload)); return; }).on('error', (payload)=>{ console.log(array[i]); console.log(JSON.stringify(payload)); return; }); }, 1500 * i) // With each iteration, the delay increases}If you wrap it correctly once I can re-use it on tons of apis... ~~ <3333 plzzzzz help1! Bonus points if you fix it so the URLs or iteration are returned alongside the stringify(payload) ~~ Whoever helps i'll give you 100k karma, promise!~

Submitted November 07, 2017 at 08:22PM by PostNationalism

No comments:

Post a Comment