I'm trying to do something after push data from reddit api to array, but callback function doesn't work at all. As you see the code, It's supposed to print Callback function works!
but It doesn't. Is there any ideas about this?
let optForReddit = {
method: 'GET',
uri: 'https://www.reddit.com/domain/eroshare.com/new.json',
json: true
}
rp(optForReddit)
.then(function(redditJSON) {
let posts = redditJSON.data.children;
let len = posts.length;
let eroJson = [];
async.each(posts, function(item, callback) {
if (isVideo(item.data.url)) {
eroJson.push(getAlbumId(item.data.url));
}
},
function(err) {
console.log("Callback function works");
if(err) console.log(err);
});
})
.catch(function(err) {
console.log(err);
})