Hi,
after a lot of hard work I finally finished my first SpookyJS script to scrape some data from a website.
Now I want to use the result in a query against the database and/or call another Meteor.method with the result as an argument, but here I run into a problem that I couldn’t fix by myself for the last few hours, so any help would be appreciated.
Here is my spooky.on code:
spooky.on('fun', function (courses) {
console.log(courses);
Meteor.call('edxResult', courses); // edxResult is never called... or at least it never gets to edxResult
console.log('debug test'); // this line is never executed
});
The console output from console.log(courses) is definitely right:
[ 'course-v1:MITx+6.00.2x_3+1T2015',
'HarvardX/CS50x3/2015',
'course-v1:LinuxFoundationX+LFS101x.2+1T2015',
'MITx/6.00.1x_5/1T2015' ]
What I tried so far, calling the Meteor.method in which spooky runs with a callback, but that callback is executed immediately, not after spooky is finished (the whole spooky script takes around 10 secs)
I am not sure if using fibers/futures would help, I have never used them, so I would probably need a lot of help how to implement them for this.