How To Sequentially Handle Asynchronous Results From Api?
This question might be a little vague, but I'll try my best to explain. I'm trying to create an array of all of the tweets that I can retrieve from Twitter's API, but it limits eac
Solution 1:
I would suggest using request-promise
instead of request
. Here is my solution.
var rp = require('request-promise');
var tweets = [];
var promises = [];
for (var i =1; i< 10; i++){
var promise = rp(options);
promises.push(promise);
}
Promise.all(promises).then(function(data){
data.forEach(function(item){
// handle tweets here
});
return res.json(tweets);
});
Post a Comment for "How To Sequentially Handle Asynchronous Results From Api?"